From: Paolo Carlini Date: Sat, 24 Jun 2017 19:31:24 +0000 (+0000) Subject: re PR c++/62315 (do not print typename in diagnostic if the original code does not... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22235619ba63b4a17f2b208958f467233c84bdb7;p=gcc.git re PR c++/62315 (do not print typename in diagnostic if the original code does not have it) /cp 2017-06-24 Paolo Carlini 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 PR c++/62315 * g++.dg/parse/typedef2.C: Specify a dg-error string. From-SVN: r249626 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d590a5d66f..a06de8ba8c7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-06-24 Paolo Carlini + + 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 PR c++/79056 - C++17 ICE with invalid template syntax. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 97cd9237bf2..634047e5d05 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 % 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 % 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 % 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 eefa2c47715..ad5ccb7dc64 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-24 Paolo Carlini + + PR c++/62315 + * g++.dg/parse/typedef2.C: Specify a dg-error string. + 2017-06-24 Thomas Koenig PR fortran/52473 diff --git a/gcc/testsuite/g++.dg/parse/typedef2.C b/gcc/testsuite/g++.dg/parse/typedef2.C index 3ae347d7542..1cc1ea0d58f 100644 --- a/gcc/testsuite/g++.dg/parse/typedef2.C +++ b/gcc/testsuite/g++.dg/parse/typedef2.C @@ -1,3 +1,2 @@ template struct B { typedef typename T::X X; }; -template struct A { typedef B::X::Y Z; }; // { dg-error "" } - +template struct A { typedef B::X::Y Z; }; // { dg-error "before 'B::X::Y' because 'B::X'" }