From: Jason Merrill Date: Wed, 27 Apr 2011 15:56:46 +0000 (-0400) Subject: re PR c++/48046 (Expected diagnostic "reference to 'type' is ambiguous" not given... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9e0541d9c0b2842b738a99a70673be0752ee591d;p=gcc.git re PR c++/48046 (Expected diagnostic "reference to 'type' is ambiguous" not given for function-local static declaration) PR c++/48046 * parser.c (cp_parser_diagnose_invalid_type_name): Commit to tentative parse sooner. From-SVN: r173036 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6e83decff2..6873f647777 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-04-27 Jason Merrill + + PR c++/48046 + * parser.c (cp_parser_diagnose_invalid_type_name): Commit + to tentative parse sooner. + 2011-04-26 Jason Merrill PR c++/42687 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 68ce052612a..89100aa2abd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2440,6 +2440,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, location_t location) { tree decl, old_scope; + cp_parser_commit_to_tentative_parse (parser); /* Try to lookup the identifier. */ old_scope = parser->scope; parser->scope = scope; @@ -2533,7 +2534,6 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, else gcc_unreachable (); } - cp_parser_commit_to_tentative_parse (parser); } /* Check for a common situation where a type-name should be present, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25cf23d3f75..328d8dcbd78 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-27 Jason Merrill + + * g++.dg/parse/ambig6.C: New. + 2011-04-27 Nick Clifton * gcc.dg/20020312-2.c: Add definition for RX. diff --git a/gcc/testsuite/g++.dg/parse/ambig6.C b/gcc/testsuite/g++.dg/parse/ambig6.C new file mode 100644 index 00000000000..8f37feaea68 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ambig6.C @@ -0,0 +1,12 @@ +// PR c++/48046 + +namespace N1 { typedef int T; } // { dg-error "" } +namespace N2 { typedef float T; } // { dg-error "" } + +int main() +{ + using namespace N1; + using namespace N2; + + static T t; // { dg-error "" } +}