diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2017-06-24 19:31:24 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2017-06-24 19:31:24 +0000 |
commit | 22235619ba63b4a17f2b208958f467233c84bdb7 (patch) | |
tree | 2889dba40a175463ca568790a086f71d98ad18b0 /gcc | |
parent | e56e3fda6092548f3cd5336d131b412be986b1e6 (diff) | |
download | gcc-22235619ba63b4a17f2b208958f467233c84bdb7.zip gcc-22235619ba63b4a17f2b208958f467233c84bdb7.tar.gz gcc-22235619ba63b4a17f2b208958f467233c84bdb7.tar.bz2 |
re PR c++/62315 (do not print typename in diagnostic if the original code does not have it)
/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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/typedef2.C | 3 |
4 files changed, 27 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d590a5..a06de8b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 97cd923..634047e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eefa2c4..ad5ccb7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/g++.dg/parse/typedef2.C b/gcc/testsuite/g++.dg/parse/typedef2.C index 3ae347d..1cc1ea0 100644 --- a/gcc/testsuite/g++.dg/parse/typedef2.C +++ b/gcc/testsuite/g++.dg/parse/typedef2.C @@ -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'" } |