]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: mem-initializer-id qualified name lookup is type-only [PR122192]
authorPatrick Palka <ppalka@redhat.com>
Tue, 14 Oct 2025 16:56:23 +0000 (12:56 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 14 Oct 2025 16:56:23 +0000 (12:56 -0400)
Since a mem-initializer needs to be able to initialize any base class,
lookup for which is type-only, we in turn need to make mem-initializer-id
qualified name lookup type-only too.

PR c++/122192

gcc/cp/ChangeLog:

* parser.cc (cp_parser_mem_initializer_id): Pass class_type
instead of typename_type to cp_parser_class_name in the
nested-name-specifier case.

gcc/testsuite/ChangeLog:

* g++.dg/template/dependent-base6.C: Verify mem-initializer-id
qualified name lookup is type-only too.

Reported-by: Vincent X
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/parser.cc
gcc/testsuite/g++.dg/template/dependent-base6.C

index 1ed2f3767e1cb1611e67467fdd282e13ddc47bc6..9280632d47b84a93ed5b08377cc3242f98d3ea2c 100644 (file)
@@ -19091,7 +19091,7 @@ cp_parser_mem_initializer_id (cp_parser* parser)
     return cp_parser_class_name (parser,
                                 /*typename_keyword_p=*/true,
                                 /*template_keyword_p=*/template_p,
-                                typename_type,
+                                class_type,
                                 /*check_dependency_p=*/true,
                                 /*class_head_p=*/false,
                                 /*is_declaration=*/true);
index b4bc5c279a58fabfc62ce4484578c81b579c73b9..9f2a7a23923f43bdb836cb72b41a3885c5da6844 100644 (file)
@@ -8,5 +8,7 @@ struct A {
 
 struct S1 : A::B { }; // OK
 
-template<class T> struct S2 : T::B { }; // OK, used to fail
+template<class T> struct S2 : T::B { // OK, used to fail
+  S2() : T::B() { } // Also OK
+};
 template struct S2<A>;