From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DC70F15800F for ; Mon, 6 Feb 2023 17:41:03 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 051A0E07EE; Mon, 6 Feb 2023 17:41:03 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DCFF7E07EE for ; Mon, 6 Feb 2023 17:41:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2821A340A9F for ; Mon, 6 Feb 2023 17:41:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3AECF89F for ; Mon, 6 Feb 2023 17:40:59 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1675705097.6d368fffaa25908cf25836feb5ab660d8d0a3d58.sam@gentoo> Subject: [gentoo-commits] proj/gcc-patches:master commit in: 12.2.0/gentoo/ X-VCS-Repository: proj/gcc-patches X-VCS-Files: 12.2.0/gentoo/76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch 12.2.0/gentoo/README.history X-VCS-Directories: 12.2.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 6d368fffaa25908cf25836feb5ab660d8d0a3d58 X-VCS-Branch: master Date: Mon, 6 Feb 2023 17:40:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d5a897a1-725c-4178-a843-69d9fbf97729 X-Archives-Hash: 1baf420caf25c05529b04049f278dd51 commit: 6d368fffaa25908cf25836feb5ab660d8d0a3d58 Author: Sam James gentoo org> AuthorDate: Mon Feb 6 17:38:06 2023 +0000 Commit: Sam James gentoo org> CommitDate: Mon Feb 6 17:38:17 2023 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=6d368fff 12.2.0: add 76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch Bug: https://bugs.gentoo.org/893410 Signed-off-by: Sam James gentoo.org> ...07461_cxx_equivalence_non_dependent_calls.patch | 204 +++++++++++++++++++++ 12.2.0/gentoo/README.history | 9 +- 2 files changed, 210 insertions(+), 3 deletions(-) diff --git a/12.2.0/gentoo/76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch b/12.2.0/gentoo/76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch new file mode 100644 index 0000000..b34cd4a --- /dev/null +++ b/12.2.0/gentoo/76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch @@ -0,0 +1,204 @@ +https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=31924665c86d47af6b1f22a74f594f2e1dc0ed2d +(12 version: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=eda24f6c12b6d3777ff3bf3656187e695a3e8dc2) +(followup to https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=59e0376f607805ef9b67fd7b0a4a3084ab3571a5) +https://bugs.gentoo.org/893410 + +From eda24f6c12b6d3777ff3bf3656187e695a3e8dc2 Mon Sep 17 00:00:00 2001 +From: Patrick Palka +Date: Sun, 5 Feb 2023 21:35:33 -0500 +Subject: [PATCH] c++: equivalence of non-dependent calls [PR107461] + +After r13-5684-g59e0376f607805 the (pruned) callee of a non-dependent +CALL_EXPR is a bare FUNCTION_DECL rather than ADDR_EXPR of FUNCTION_DECL. +This innocent change revealed that cp_tree_equal doesn't first check +dependence of a CALL_EXPR before treating a FUNCTION_DECL callee as a +dependent name, which leads to us incorrectly accepting the first two +testcases below and rejecting the third: + + * In the first testcase, cp_tree_equal incorrectly returns true for + the two non-dependent CALL_EXPRs f(0) and f(0) (whose CALL_EXPR_FN + are different FUNCTION_DECLs) which causes us to treat #2 as a + redeclaration of #1. + + * Same issue in the second testcase, for f() and f(). + + * In the third testcase, cp_tree_equal incorrectly returns true for + f() and f() which causes us to conflate the two + dependent specializations A()(U()))> and + A()(U()))>. + +This patch fixes this by making called_fns_equal treat two callees as +dependent names only if the overall CALL_EXPRs are dependent, via a new +convenience function call_expr_dependent_name that is like dependent_name +but also checks dependence of the overall CALL_EXPR. + + PR c++/107461 + +gcc/cp/ChangeLog: + + * cp-tree.h (call_expr_dependent_name): Declare. + * pt.cc (iterative_hash_template_arg) : Use + call_expr_dependent_name instead of dependent_name. + * tree.cc (call_expr_dependent_name): Define. + (called_fns_equal): Adjust to take two CALL_EXPRs instead of + CALL_EXPR_FNs thereof. Use call_expr_dependent_name instead + of dependent_name. + (cp_tree_equal) : Adjust call to called_fns_equal. + +gcc/testsuite/ChangeLog: + + * g++.dg/cpp0x/overload5.C: New test. + * g++.dg/cpp0x/overload5a.C: New test. + * g++.dg/cpp0x/overload6.C: New test. + +(cherry picked from commit 31924665c86d47af6b1f22a74f594f2e1dc0ed2d) +--- + gcc/cp/cp-tree.h | 1 + + gcc/cp/pt.cc | 2 +- + gcc/cp/tree.cc | 24 +++++++++++++++++++----- + gcc/testsuite/g++.dg/cpp0x/overload5.C | 12 ++++++++++++ + gcc/testsuite/g++.dg/cpp0x/overload5a.C | 10 ++++++++++ + gcc/testsuite/g++.dg/cpp0x/overload6.C | 16 ++++++++++++++++ + 6 files changed, 59 insertions(+), 6 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/overload5.C + create mode 100644 gcc/testsuite/g++.dg/cpp0x/overload5a.C + create mode 100644 gcc/testsuite/g++.dg/cpp0x/overload6.C + +diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h +index cd51dd288b0..40563a151fe 100644 +--- a/gcc/cp/cp-tree.h ++++ b/gcc/cp/cp-tree.h +@@ -7860,6 +7860,7 @@ extern tree lookup_maybe_add (tree fns, tree lookup, + extern int is_overloaded_fn (tree) ATTRIBUTE_PURE; + extern bool really_overloaded_fn (tree) ATTRIBUTE_PURE; + extern tree dependent_name (tree); ++extern tree call_expr_dependent_name (tree); + extern tree maybe_get_fns (tree) ATTRIBUTE_PURE; + extern tree get_fns (tree) ATTRIBUTE_PURE; + extern tree get_first_fn (tree) ATTRIBUTE_PURE; +diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc +index 735c106c7d6..0af7033589a 100644 +--- a/gcc/cp/pt.cc ++++ b/gcc/cp/pt.cc +@@ -1910,7 +1910,7 @@ iterative_hash_template_arg (tree arg, hashval_t val) + case CALL_EXPR: + { + tree fn = CALL_EXPR_FN (arg); +- if (tree name = dependent_name (fn)) ++ if (tree name = call_expr_dependent_name (arg)) + { + if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) + val = iterative_hash_template_arg (TREE_OPERAND (fn, 1), val); +diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc +index bc521f8ae9c..e8a9c473ef6 100644 +--- a/gcc/cp/tree.cc ++++ b/gcc/cp/tree.cc +@@ -2596,6 +2596,18 @@ dependent_name (tree x) + return NULL_TREE; + } + ++/* Like dependent_name, but instead takes a CALL_EXPR and also checks ++ its dependence. */ ++ ++tree ++call_expr_dependent_name (tree x) ++{ ++ if (TREE_TYPE (x) != NULL_TREE) ++ /* X isn't dependent, so its callee isn't a dependent name. */ ++ return NULL_TREE; ++ return dependent_name (CALL_EXPR_FN (x)); ++} ++ + /* Returns true iff X is an expression for an overloaded function + whose type cannot be known without performing overload + resolution. */ +@@ -3829,16 +3841,18 @@ decl_anon_ns_mem_p (const_tree decl) + return !TREE_PUBLIC (decl); + } + +-/* Subroutine of cp_tree_equal: t1 and t2 are the CALL_EXPR_FNs of two +- CALL_EXPRS. Return whether they are equivalent. */ ++/* Subroutine of cp_tree_equal: t1 and t2 are two CALL_EXPRs. ++ Return whether their CALL_EXPR_FNs are equivalent. */ + + static bool + called_fns_equal (tree t1, tree t2) + { + /* Core 1321: dependent names are equivalent even if the overload sets + are different. But do compare explicit template arguments. */ +- tree name1 = dependent_name (t1); +- tree name2 = dependent_name (t2); ++ tree name1 = call_expr_dependent_name (t1); ++ tree name2 = call_expr_dependent_name (t2); ++ t1 = CALL_EXPR_FN (t1); ++ t2 = CALL_EXPR_FN (t2); + if (name1 || name2) + { + tree targs1 = NULL_TREE, targs2 = NULL_TREE; +@@ -3952,7 +3966,7 @@ cp_tree_equal (tree t1, tree t2) + if (KOENIG_LOOKUP_P (t1) != KOENIG_LOOKUP_P (t2)) + return false; + +- if (!called_fns_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2))) ++ if (!called_fns_equal (t1, t2)) + return false; + + call_expr_arg_iterator iter1, iter2; +diff --git a/gcc/testsuite/g++.dg/cpp0x/overload5.C b/gcc/testsuite/g++.dg/cpp0x/overload5.C +new file mode 100644 +index 00000000000..e05b1594f51 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/overload5.C +@@ -0,0 +1,12 @@ ++// PR c++/107461 ++// { dg-do compile { target c++11 } } ++ ++int f(...); ++template decltype(T() + f(0)) g(); // #1 ++ ++char f(int); ++template decltype(T() + f(0)) g(); // #2, distinct from #1 ++ ++int main() { ++ g(); // { dg-error "ambiguous" } ++} +diff --git a/gcc/testsuite/g++.dg/cpp0x/overload5a.C b/gcc/testsuite/g++.dg/cpp0x/overload5a.C +new file mode 100644 +index 00000000000..037114f199c +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/overload5a.C +@@ -0,0 +1,10 @@ ++// PR c++/107461 ++// { dg-do compile { target c++11 } } ++ ++template T f(); ++template decltype(T() + f()) g(); // #1 ++template decltype(T() + f()) g(); // #2, distinct from #1 ++ ++int main() { ++ g(); // { dg-error "ambiguous" } ++} +diff --git a/gcc/testsuite/g++.dg/cpp0x/overload6.C b/gcc/testsuite/g++.dg/cpp0x/overload6.C +new file mode 100644 +index 00000000000..1fbee0501de +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/overload6.C +@@ -0,0 +1,16 @@ ++// PR c++/107461 ++// { dg-do compile { target c++11 } } ++ ++template T f(); ++ ++template struct A { }; ++ ++template struct B { ++ template()(U()))>> ++ static void g(U); ++}; ++ ++int main() { ++ B b; ++ B::g(0); // { dg-bogus "no match" } ++} +-- +2.31.1 diff --git a/12.2.0/gentoo/README.history b/12.2.0/gentoo/README.history index 940ed88..4437361 100644 --- a/12.2.0/gentoo/README.history +++ b/12.2.0/gentoo/README.history @@ -1,10 +1,13 @@ -11 29 Jan 2022 +12 6 Feb 2023 + + 76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch + +11 29 Jan 2023 - 76_all_driver_environ_putenv_PR106624.patch -10 23 Jan 2022 +10 23 Jan 2023 + 76_all_driver_environ_putenv_PR106624.patch -9 8 Jan 2022 +9 8 Jan 2023 - 76_all_libsanitizer-implicit-function-decls.patch - 77_all_libiberty-fix-c89-isms-in-configure.patch