re PR c++/48046 (Expected diagnostic "reference to 'type' is ambiguous" not given...
authorJason Merrill <jason@redhat.com>
Wed, 27 Apr 2011 15:56:46 +0000 (11:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 27 Apr 2011 15:56:46 +0000 (11:56 -0400)
PR c++/48046
* parser.c (cp_parser_diagnose_invalid_type_name): Commit
to tentative parse sooner.

From-SVN: r173036

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/ambig6.C [new file with mode: 0644]

index c6e83decff2a95856e101ced725ab98c43f78ef2..6873f64777765296b69744a49ee543ad94476118 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/48046
+       * parser.c (cp_parser_diagnose_invalid_type_name): Commit
+       to tentative parse sooner.
+
 2011-04-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/42687
index 68ce052612a2e6e3ff2ae2798e0704c529be26f5..89100aa2abd463b2707ad4430b928cb44fdef3cb 100644 (file)
@@ -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,
index 25cf23d3f75089893a06cc3fabd0fbbf88fc42fc..328d8dcbd7888424942cfaeade90d5703e473208 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-27  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/parse/ambig6.C: New.
+
 2011-04-27  Nick Clifton  <nickc@redhat.com>
 
        * 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 (file)
index 0000000..8f37fea
--- /dev/null
@@ -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 "" }
+}