diff mbox

Fix PR c++/59638

Message ID 1388829298-14606-1-git-send-email-adam@jessamine.co.uk
State New
Headers show

Commit Message

Adam Butcher Jan. 4, 2014, 9:54 a.m. UTC
* cp/parser.c (cp_parser_init_declarator): Undo fully implicit
	template parameter list when declarator is not a function.

	* g++.dg/cpp1y/pr59638.C: New testcase.
---
 gcc/cp/parser.c                      |  8 ++++++++
 gcc/testsuite/g++.dg/cpp1y/pr59638.C | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59638.C

Comments

Jason Merrill Jan. 6, 2014, 2:36 p.m. UTC | #1
On 01/04/2014 04:54 AM, Adam Butcher wrote:
> +  /* Declarations involving function parameter lists containing implicit
> +     template parameters will have been made into implicit templates.  If they
> +     do not turn out to be actual function declarations then finish the
> +     template declaration here.  */

This will always be an error, right?  Please mention that in the 
comment.  OK with that change.

Jason
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 0e013b9..991588d 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -16784,6 +16784,14 @@  cp_parser_init_declarator (cp_parser* parser,
       warning (OPT_Wattributes,
 	       "attributes after parenthesized initializer ignored");
 
+  /* Declarations involving function parameter lists containing implicit
+     template parameters will have been made into implicit templates.  If they
+     do not turn out to be actual function declarations then finish the
+     template declaration here.  */
+  if (parser->fully_implicit_function_template_p)
+    if (!function_declarator_p (declarator))
+      finish_fully_implicit_template (parser, /*member_decl_opt=*/0);
+
   /* For an in-class declaration, use `grokfield' to create the
      declaration.  */
   if (member_p)
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59638.C b/gcc/testsuite/g++.dg/cpp1y/pr59638.C
new file mode 100644
index 0000000..cd9dcdf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59638.C
@@ -0,0 +1,16 @@ 
+// { dg-do compile }
+// { dg-options "-std=gnu++1y" }
+
+// PR c++/59638
+
+
+void (*a)(auto);         // { dg-error "template declaration" }
+
+void (*b)(auto) = 0;     // { dg-error "template declaration" }
+
+typedef void (*f)(auto); // { dg-error "template declaration" }
+
+struct A
+{
+  int i;
+};