From: Jason Merrill Date: Thu, 28 Apr 2011 15:02:17 +0000 (-0400) Subject: re PR c++/48046 (Expected diagnostic "reference to 'type' is ambiguous" not given... X-Git-Tag: releases/gcc-4.5.4~678 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c1811fc4f9d392f3f11bea59700a03274603f5a;p=thirdparty%2Fgcc.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: r173116 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c9f9f0d1063a..997c7688a444 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-28 Release Manager * GCC 4.5.3 released. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d83283b634fa..2632d3e422de 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2333,6 +2333,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; @@ -2423,7 +2424,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 4a1a246cce75..62656be1d4fd 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-28 Release Manager * GCC 4.5.3 released. diff --git a/gcc/testsuite/g++.dg/parse/ambig6.C b/gcc/testsuite/g++.dg/parse/ambig6.C new file mode 100644 index 000000000000..8f37feaea685 --- /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 "" } +}