This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/62315] do not print typename in diagnostic if the original code does not have it


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))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]