Patchwork Fix PR c++/60626

login
register
mail settings
Submitter Adam Butcher
Date March 24, 2014, 9:33 p.m.
Message ID <1395696837-908-1-git-send-email-adam@jessamine.co.uk>
Download mbox | patch
Permalink /patch/333173/
State New
Headers show

Comments

Adam Butcher - March 24, 2014, 9:33 p.m.
PR c++/60626
	* parser.c (cp_parser_init_declarator): Handle erroneous generic type
	usage in non-functions with pushed scope.

	PR c++/60626
	* g++.dg/cpp1y/pr60626.C: New testcase.
---
 gcc/cp/parser.c                      | 9 ++++++++-
 gcc/testsuite/g++.dg/cpp1y/pr60626.C | 7 +++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60626.C
Jason Merrill - March 29, 2014, 2:08 p.m.
OK.

Jason

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index efb7b39..49fb731 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16823,7 +16823,14 @@  cp_parser_init_declarator (cp_parser* parser,
      been issued.  */
   if (parser->fully_implicit_function_template_p)
     if (!function_declarator_p (declarator))
-      finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+      {
+	if (pushed_scope)
+	  {
+	    pop_scope (pushed_scope);
+	    pushed_scope = 0;
+	  }
+	finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+      }
 
   /* For an in-class declaration, use `grokfield' to create the
      declaration.  */
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60626.C b/gcc/testsuite/g++.dg/cpp1y/pr60626.C
new file mode 100644
index 0000000..39ea438
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60626.C
@@ -0,0 +1,7 @@ 
+// PR c++/60626
+// { dg-do compile { target c++1y } }
+// { dg-options "" }
+
+struct A {};
+
+void (*A::p)(auto) = 0;  // { dg-error "static member|non-template" }