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.
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
--- /dev/null
+// PR c++/41723
+
+template<class T>
+class C {
+ template <class U> class D {};
+
+ friend class C::D<int>;
+};