Patchwork Fix PR c++/60393

login
register
mail settings
Submitter Adam Butcher
Date March 7, 2014, 11:09 p.m.
Message ID <1394233749-23758-1-git-send-email-adam@jessamine.co.uk>
Download mbox | patch
Permalink /patch/328117/
State New
Headers show

Comments

Adam Butcher - March 7, 2014, 11:09 p.m.
PR c++/60393
	* parser.c (cp_parser_parameter_declaration_clause): Move generic
	function template unwinding on error into a more general location, ...
	(cp_parser_skip_to_end_of_statement): ... here.

	PR c++/60393
	* g++.dg/cpp1y/pr60393.C: New testcase.
---
 gcc/cp/parser.c                      | 11 +++++------
 gcc/testsuite/g++.dg/cpp1y/pr60393.C |  9 +++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60393.C
Jason Merrill - March 8, 2014, 4:01 a.m.
OK.

Jason

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 8c78262..523a059 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3128,6 +3128,10 @@  cp_parser_skip_to_end_of_statement (cp_parser* parser)
 {
   unsigned nesting_depth = 0;
 
+  /* Unwind generic function template scope if necessary.  */
+  if (parser->fully_implicit_function_template_p)
+    finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+
   while (true)
     {
       cp_token *token = cp_lexer_peek_token (parser->lexer);
@@ -18208,12 +18212,7 @@  cp_parser_parameter_declaration_clause (cp_parser* parser)
      parameter-declaration-list, then the entire
      parameter-declaration-clause is erroneous.  */
   if (is_error)
-    {
-      /* Unwind generic function template scope if necessary.  */
-      if (parser->fully_implicit_function_template_p)
-	finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
-      return NULL;
-    }
+    return NULL;
 
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60393.C b/gcc/testsuite/g++.dg/cpp1y/pr60393.C
new file mode 100644
index 0000000..38b8b91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60393.C
@@ -0,0 +1,9 @@ 
+// PR c++/60393
+// { dg-options -std=c++1y }
+
+void (*f)(auto) + 0; // { dg-error "expected" }
+
+struct A
+{
+  int i;
+};