re PR c++/62315 (do not print typename in diagnostic if the original code does not...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 24 Jun 2017 19:31:24 +0000 (19:31 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 24 Jun 2017 19:31:24 +0000 (19:31 +0000)
/cp
2017-06-24  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/62315
* parser.c (cp_parser_diagnose_invalid_type_name): Don't print
'typename' in error messages about missing 'typename'.

/testsuite
2017-06-24  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/62315
* g++.dg/parse/typedef2.C: Specify a dg-error string.

From-SVN: r249626

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/typedef2.C

index 2d590a5d66f074964a74038572cd62beda98de5f..a06de8ba8c73e7982e25d19e1455463f836840e0 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/62315
+       * parser.c (cp_parser_diagnose_invalid_type_name): Don't print
+       'typename' in error messages about missing 'typename'.
+
 2017-06-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/79056 - C++17 ICE with invalid template syntax.
index 97cd9237bf20e44973bb433e789013f6a18fd023..634047e5d05d167a8e5e15dcbbac71f0a125f38c 100644 (file)
@@ -3272,9 +3272,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id,
        }
       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 eefa2c4771556868aa37ede8af50c37c09ca4dcc..ad5ccb7dc64a5461c91658c98021a0bc54aade6e 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/62315
+       * g++.dg/parse/typedef2.C: Specify a dg-error string.
+
 2017-06-24  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
         PR fortran/52473
index 3ae347d75427840cd11696da9529fa1dc29466a4..1cc1ea0d58ff26f178e1e69cfb961ec5f24166c4 100644 (file)
@@ -1,3 +1,2 @@
 template <typename T> struct B { typedef typename T::X X; };
-template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "" }
+template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "before 'B<T>::X::Y' because 'B<T>::X'" }