@@ -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,
new file mode 100644
@@ -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 "" }
+}