aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2024-10-04 10:27:50 +0100
committerSam James <sam@gentoo.org>2024-10-04 10:27:50 +0100
commitf44cf391c1dbacd2651298e2fb366905a5fe0a06 (patch)
tree2964024dc5a425e82c9d27b8f851e9635b95507d
parent15.0.0: drop 71_all_PR116878-libcall.patch (diff)
downloadgcc-patches-f44cf391c1dbacd2651298e2fb366905a5fe0a06.tar.gz
gcc-patches-f44cf391c1dbacd2651298e2fb366905a5fe0a06.tar.bz2
gcc-patches-f44cf391c1dbacd2651298e2fb366905a5fe0a06.zip
15.0.0: add two C++ patches
+ 71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch + 72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--15.0.0/gentoo/71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch96
-rw-r--r--15.0.0/gentoo/72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch76
-rw-r--r--15.0.0/gentoo/README.history4
3 files changed, 175 insertions, 1 deletions
diff --git a/15.0.0/gentoo/71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch b/15.0.0/gentoo/71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch
new file mode 100644
index 0000000..4e2f1f4
--- /dev/null
+++ b/15.0.0/gentoo/71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch
@@ -0,0 +1,96 @@
+From 923bd335a44b1b556d705a7f1d36a2e9c06d9c5c Mon Sep 17 00:00:00 2001
+Message-ID: <923bd335a44b1b556d705a7f1d36a2e9c06d9c5c.1728034006.git.sam@gentoo.org>
+From: Nathaniel Shead <nathanieloshead@gmail.com>
+Date: Fri, 4 Oct 2024 12:41:49 +1000
+Subject: [PATCH 1/2] c++: Allow references to internal-linkage vars in C++11
+ [PR113266]
+
+[temp.arg.nontype] changed in C++11 to allow naming internal-linkage
+variables and functions. We currently already handle internal-linkage
+functions, but variables were missed; this patch updates this.
+
+ PR c++/113266
+ PR c++/116911
+
+gcc/cp/ChangeLog:
+
+ * parser.cc (cp_parser_template_argument): Allow
+ internal-linkage variables since C++11.
+
+gcc/testsuite/ChangeLog:
+
+ * g++.dg/cpp0x/nontype6.C: New test.
+
+Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
+---
+ gcc/cp/parser.cc | 17 ++++++++++++-----
+ gcc/testsuite/g++.dg/cpp0x/nontype6.C | 19 +++++++++++++++++++
+ 2 files changed, 31 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/testsuite/g++.dg/cpp0x/nontype6.C
+
+diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
+index 08f9c89f1f0..e758ddeb1d5 100644
+--- a/gcc/cp/parser.cc
++++ b/gcc/cp/parser.cc
+@@ -19864,9 +19864,11 @@ cp_parser_template_argument (cp_parser* parser)
+
+ -- the name of a non-type template-parameter; or
+
+- -- the name of an object or function with external linkage...
++ -- the name of an object or function with external (or internal,
++ since C++11) linkage...
+
+- -- the address of an object or function with external linkage...
++ -- the address of an object or function with external (or internal,
++ since C++11) linkage...
+
+ -- a pointer to member... */
+ /* Look for a non-type template parameter. */
+@@ -19929,11 +19931,16 @@ cp_parser_template_argument (cp_parser* parser)
+ probe = TREE_OPERAND (probe, 1);
+ if (VAR_P (probe))
+ {
+- /* A variable without external linkage might still be a
++ /* A variable without valid linkage might still be a
+ valid constant-expression, so no error is issued here
+ if the external-linkage check fails. */
+- if (!address_p && !DECL_EXTERNAL_LINKAGE_P (probe))
+- cp_parser_simulate_error (parser);
++ if (!address_p && cxx_dialect < cxx17)
++ {
++ linkage_kind linkage = decl_linkage (probe);
++ if (linkage != lk_external
++ && (cxx_dialect < cxx11 || linkage != lk_internal))
++ cp_parser_simulate_error (parser);
++ }
+ }
+ else if (is_overloaded_fn (argument))
+ /* All overloaded functions are allowed; if the external
+diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype6.C b/gcc/testsuite/g++.dg/cpp0x/nontype6.C
+new file mode 100644
+index 00000000000..5543d1e8b6d
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/cpp0x/nontype6.C
+@@ -0,0 +1,19 @@
++// PR c++/113266, PR c++/116911
++// { dg-do compile }
++
++template <int &> struct a {};
++static int guard1;
++a<guard1> b; // { dg-error "constant-expression|invalid" "" { target c++98_only } }
++
++namespace {
++ int guard2;
++}
++a<guard2> c; // OK in C++98 because guard2 has external linkage
++ // OK since C++11 because we can refer to an internal linkage decl
++
++void nolinkage() {
++ static int guard3;
++ a<guard3> d; // { dg-error "constant-expression|invalid" "" { target c++98_only } }
++ // { dg-error "constant expression|no linkage" "" { target { c++11 && c++14_down } } .-1 }
++ // OK since C++17 since we can now refer to no-linkage decls
++}
+--
+2.46.2
+
diff --git a/15.0.0/gentoo/72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch b/15.0.0/gentoo/72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch
new file mode 100644
index 0000000..ab12bf6
--- /dev/null
+++ b/15.0.0/gentoo/72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch
@@ -0,0 +1,76 @@
+From ba7c4e109fc589603911630deb2f19eba88bdbe8 Mon Sep 17 00:00:00 2001
+Message-ID: <ba7c4e109fc589603911630deb2f19eba88bdbe8.1728034006.git.sam@gentoo.org>
+In-Reply-To: <923bd335a44b1b556d705a7f1d36a2e9c06d9c5c.1728034006.git.sam@gentoo.org>
+References: <923bd335a44b1b556d705a7f1d36a2e9c06d9c5c.1728034006.git.sam@gentoo.org>
+From: Nathaniel Shead <nathanieloshead@gmail.com>
+Date: Fri, 4 Oct 2024 10:52:02 +1000
+Subject: [PATCH 2/2] c++: Return the underlying decl rather than the
+ USING_DECL from update_binding [PR116913]
+
+Users of pushdecl assume that the returned decl will be a possibly
+updated decl matching the one that was passed in. My r15-3910 change
+broke this since in some cases we would now return USING_DECLs; this
+patch fixes the situation.
+
+ PR c++/116913
+
+gcc/cp/ChangeLog:
+
+ * name-lookup.cc (update_binding): Return the strip_using'd old
+ decl rather than the binding.
+
+gcc/testsuite/ChangeLog:
+
+ * g++.dg/lookup/using70.C: New test.
+
+Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
+---
+ gcc/cp/name-lookup.cc | 4 ++--
+ gcc/testsuite/g++.dg/lookup/using70.C | 13 +++++++++++++
+ 2 files changed, 15 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/testsuite/g++.dg/lookup/using70.C
+
+diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
+index 4754ef5a522..609bd6e8c9b 100644
+--- a/gcc/cp/name-lookup.cc
++++ b/gcc/cp/name-lookup.cc
+@@ -3101,7 +3101,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot,
+ {
+ if (same_type_p (TREE_TYPE (old), TREE_TYPE (decl)))
+ /* Two type decls to the same type. Do nothing. */
+- return old_bval;
++ return old;
+ else
+ goto conflict;
+ }
+@@ -3114,7 +3114,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot,
+
+ /* The new one must be an alias at this point. */
+ gcc_assert (DECL_NAMESPACE_ALIAS (decl));
+- return old_bval;
++ return old;
+ }
+ else if (TREE_CODE (old) == VAR_DECL)
+ {
+diff --git a/gcc/testsuite/g++.dg/lookup/using70.C b/gcc/testsuite/g++.dg/lookup/using70.C
+new file mode 100644
+index 00000000000..14838eea7ec
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/lookup/using70.C
+@@ -0,0 +1,13 @@
++// PR c++/116913
++// { dg-do compile { target c++11 } }
++
++namespace ns {
++ struct c {};
++ using d = int;
++}
++
++using ns::c;
++using ns::d;
++
++using c = ns::c;
++using d = ns::d;
+--
+2.46.2
+
diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history
index d966e4c..2d85dc2 100644
--- a/15.0.0/gentoo/README.history
+++ b/15.0.0/gentoo/README.history
@@ -1,7 +1,9 @@
-14 ????
+14 4 October 2024
- 70_all_middle-end-check-explicitly-for-external-or-constant.patch
- 71_all_PR116878-libcall.patch
+ + 71_all_c-Allow-references-to-internal-linkage-vars-in-C-11-.patch
+ + 72_all_c-Return-the-underlying-decl-rather-than-the-USING_D.patch
13 29 September 2024