]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: friend with redundant qualification [PR41723]
authorJason Merrill <jason@redhat.com>
Wed, 7 Apr 2021 20:42:44 +0000 (16:42 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 7 Apr 2021 21:01:52 +0000 (17:01 -0400)
Different code paths were correctly choosing to look up D directly, since C
is the current instantiation, but here we decided to try to make it a
typename type, leading to confusion.  Fixed by using dependent_scope_p as we
do elsewhere.

gcc/cp/ChangeLog:

PR c++/41723
* parser.c (cp_parser_class_name): Check dependent_scope_p.

gcc/testsuite/ChangeLog:

PR c++/41723
* g++.dg/template/friend71.C: New test.

gcc/cp/parser.c
gcc/testsuite/g++.dg/template/friend71.C [new file with mode: 0644]

index c915d6415dedd73606c78c31faa6344d03ed1b96..59adac4492a151437e763386b1a717c6a7d95fc0 100644 (file)
@@ -24639,7 +24639,7 @@ cp_parser_class_name (cp_parser *parser,
   const bool typename_p = (typename_keyword_p
                           && parser->scope
                           && TYPE_P (parser->scope)
-                          && dependent_type_p (parser->scope));
+                          && dependent_scope_p (parser->scope));
   /* Handle the common case (an identifier, but not a template-id)
      efficiently.  */
   if (token->type == CPP_NAME
diff --git a/gcc/testsuite/g++.dg/template/friend71.C b/gcc/testsuite/g++.dg/template/friend71.C
new file mode 100644 (file)
index 0000000..939ea6b
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/41723
+
+template<class T>
+class C {
+  template <class U> class D {};
+
+  friend class C::D<int>;
+};