aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-01-15 17:01:33 -0500
committerPatrick Palka <ppalka@redhat.com>2024-01-15 17:01:33 -0500
commitf40076fa8291600c63d76f528cef0ce4c1f81f6e (patch)
tree2e542b9e3bc229d38141ffd4f04e516d33b17d2d /gcc/cp
parent47673571b28278d857371167f4b67a04a1b87b59 (diff)
downloadgcc-f40076fa8291600c63d76f528cef0ce4c1f81f6e.zip
gcc-f40076fa8291600c63d76f528cef0ce4c1f81f6e.tar.gz
gcc-f40076fa8291600c63d76f528cef0ce4c1f81f6e.tar.bz2
c++: access of class-scope partial spec
Since partial specializations can't be named directly, their access when declared at class scope is irrelevant, so we shouldn't have to set their TREE_PRIVATE / TREE_PROTECTED in maybe_new_partial_specialization (which is used only for constrained partial specializations anyway). This code was added by r10-4833-gcce3c9db9e6ffa for PR92078, but it seems better to just disable the access consistency check for partial specializations, which lets us accept the below testcase. gcc/cp/ChangeLog: * parser.cc (cp_parser_check_access_in_redeclaration): Don't check access for a partial or explicit specialization. * pt.cc (maybe_new_partial_specialization): Don't set TREE_PRIVATE or TREE_PROTECTED on the newly created partial specialization. gcc/testsuite/ChangeLog: * g++.dg/template/partial-specialization14.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/parser.cc3
-rw-r--r--gcc/cp/pt.cc2
2 files changed, 2 insertions, 3 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 8ab98cc..fd614ba 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -35306,7 +35306,8 @@ static void
cp_parser_check_access_in_redeclaration (tree decl, location_t location)
{
if (!decl
- || (!CLASS_TYPE_P (TREE_TYPE (decl))
+ || (!(CLASS_TYPE_P (TREE_TYPE (decl))
+ && !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl)))
&& TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE))
return;
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 8d050e8..b611723 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -978,8 +978,6 @@ maybe_new_partial_specialization (tree& type)
tree d = create_implicit_typedef (DECL_NAME (tmpl), t);
DECL_CONTEXT (d) = TYPE_CONTEXT (t);
DECL_SOURCE_LOCATION (d) = input_location;
- TREE_PRIVATE (d) = (current_access_specifier == access_private_node);
- TREE_PROTECTED (d) = (current_access_specifier == access_protected_node);
TREE_PUBLIC (d) = TREE_PUBLIC (DECL_TEMPLATE_RESULT (tmpl));
set_instantiating_module (d);