aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-04-07 16:42:44 -0400
committerJason Merrill <jason@redhat.com>2021-04-07 17:01:52 -0400
commitfb5ed6d8c90a4bf8e677a3ff9bd79d83636ccff9 (patch)
tree120e37bf2873827c380a32ca57629c67ce9a73c4
parentb40d45cb1930e9aa8a1f9a6a8728fd47ebeeaaac (diff)
downloadgcc-fb5ed6d8c90a4bf8e677a3ff9bd79d83636ccff9.zip
gcc-fb5ed6d8c90a4bf8e677a3ff9bd79d83636ccff9.tar.gz
gcc-fb5ed6d8c90a4bf8e677a3ff9bd79d83636ccff9.tar.bz2
c++: friend with redundant qualification [PR41723]
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.
-rw-r--r--gcc/cp/parser.c2
-rw-r--r--gcc/testsuite/g++.dg/template/friend71.C8
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c915d64..59adac4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
index 0000000..939ea6b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend71.C
@@ -0,0 +1,8 @@
+// PR c++/41723
+
+template<class T>
+class C {
+ template <class U> class D {};
+
+ friend class C::D<int>;
+};