diff mbox

C++ PATCH for c++/60415 (bogus qualified-id error)

Message ID 53164FBF.3040604@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 4, 2014, 10:12 p.m. UTC
We shouldn't give a hard error about a qualified-id in a function-local 
declarator when we're parsing tentatively.  Easy enough to fix by 
marking the declarator as erroneous when we see the problem.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit a758d04379a1bd0752bdcee9695a6d0d953a59ac
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 4 11:54:21 2014 -0500

    	PR c++/60415
    	PR c++/54359
    	* parser.c (cp_parser_direct_declarator): Set declarator to
    	cp_error_declarator on invalid qualified-id.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 413ada6..bb7d268 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17456,6 +17456,7 @@  cp_parser_direct_declarator (cp_parser* parser,
 		  /* But declarations with qualified-ids can't appear in a
 		     function.  */
 		  cp_parser_error (parser, "qualified-id in declaration");
+		  declarator = cp_error_declarator;
 		  break;
 		}
 	      pushed_scope = push_scope (scope);
diff --git a/gcc/testsuite/g++.dg/parse/ambig8.C b/gcc/testsuite/g++.dg/parse/ambig8.C
new file mode 100644
index 0000000..016df8a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ambig8.C
@@ -0,0 +1,15 @@ 
+// PR c++/60415
+
+namespace b {
+  enum type_t { warning };
+}
+
+struct d {
+  d(b::type_t) { }
+  int operator()() { return 0; }
+};
+
+int main()
+{
+  d(b::warning)() + 1;
+}