From 25f05e7bf142ad370a0da6681a6971ce565dc5c2 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 23 Jul 2015 10:11:48 +0000 Subject: [PATCH] re PR c++/52987 (bogus expected ; before for undeclared type) /cp 2015-07-23 Paolo Carlini PR c++/52987 * parser.c (cp_parser_simple_declaration): Robustify check avoiding redundant error messages. /testsuite 2015-07-23 Paolo Carlini PR c++/52987 * g++.dg/parse/error57.C: New. * g++.dg/expr/string-2.C: Update. From-SVN: r226097 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 3 ++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/expr/string-2.C | 2 +- gcc/testsuite/g++.dg/parse/error57.C | 4 ++++ 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/error57.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bb0385d8b17..7626492934a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-07-23 Paolo Carlini + + PR c++/52987 + * parser.c (cp_parser_simple_declaration): Robustify check avoiding + redundant error messages. + 2015-07-21 Paolo Carlini * decl.c (grokdeclarator): For an erroneous template parameter diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f1d5656055c..920cb61ee06 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11660,7 +11660,8 @@ cp_parser_simple_declaration (cp_parser* parser, { /* If we have already issued an error message we don't need to issue another one. */ - if (decl != error_mark_node + if ((decl != error_mark_node + && DECL_INITIAL (decl) != error_mark_node) || cp_parser_uncommitted_to_tentative_parse_p (parser)) cp_parser_error (parser, "expected %<,%> or %<;%>"); /* Skip tokens until we reach the end of the statement. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20fad268d2d..fe273a8d861 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-07-23 Paolo Carlini + + PR c++/52987 + * g++.dg/parse/error57.C: New. + * g++.dg/expr/string-2.C: Update. + 2015-07-23 Richard Biener PR tree-optimization/66945 diff --git a/gcc/testsuite/g++.dg/expr/string-2.C b/gcc/testsuite/g++.dg/expr/string-2.C index 252fa70364a..224fd61e086 100644 --- a/gcc/testsuite/g++.dg/expr/string-2.C +++ b/gcc/testsuite/g++.dg/expr/string-2.C @@ -4,7 +4,7 @@ char a[1]; int foo(a = "") // { dg-error "invalid array assignment" } -{ // { dg-error "" } +{ return 0; } diff --git a/gcc/testsuite/g++.dg/parse/error57.C b/gcc/testsuite/g++.dg/parse/error57.C new file mode 100644 index 00000000000..8325a0c6d07 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error57.C @@ -0,0 +1,4 @@ +// PR c++/52987 + +int foo(x a) { // { dg-error "9:'x' was not declared in this scope" } +} -- 2.30.2