This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/62315] do not print typename in diagnostic if the original code does not have it
- From: "paolo.carlini at oracle dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 02 Jun 2017 00:32:42 +0000
- Subject: [Bug c++/62315] do not print typename in diagnostic if the original code does not have it
- Auto-submitted: auto-generated
- References: <bug-62315-4@http.gcc.gnu.org/bugzilla/>
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))