https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62315
Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2017-06-02 Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com Ever confirmed|0 |1 --- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> --- In such cases of TYPENAME_TYPEs, printing separately TYPE_CONTEXT and TYPENAME_TYPE_FULLNAME, like we already do in grokdeclarator, should work: Index: parser.c =================================================================== --- parser.c (revision 248783) +++ parser.c (working copy) @@ -3270,9 +3270,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *p } else if (TYPE_P (parser->scope) && dependent_scope_p (parser->scope)) - error_at (location, "need %<typename%> before %<%T::%E%> because " - "%qT is a dependent scope", - parser->scope, id, parser->scope); + { + if (TREE_CODE (parser->scope) == TYPENAME_TYPE) + error_at (location, + "need %<typename%> before %<%T::%D::%E%> because " + "%<%T::%D%> is a dependent scope", + TYPE_CONTEXT (parser->scope), + TYPENAME_TYPE_FULLNAME (parser->scope), + id, + TYPE_CONTEXT (parser->scope), + TYPENAME_TYPE_FULLNAME (parser->scope)); + else + error_at (location, "need %<typename%> before %<%T::%E%> because " + "%qT is a dependent scope", + parser->scope, id, parser->scope); + } else if (TYPE_P (parser->scope)) { if (!COMPLETE_TYPE_P (parser->scope))