]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/59638 ([c++1y] ICE with pointer to function that has auto as parameter)
authorAdam Butcher <adam@jessamine.co.uk>
Mon, 6 Jan 2014 18:22:48 +0000 (18:22 +0000)
committerAdam Butcher <abutcher@gcc.gnu.org>
Mon, 6 Jan 2014 18:22:48 +0000 (18:22 +0000)
Fix PR c++/59638

PR c++/59638
* 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.

From-SVN: r206371

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr59638.C [new file with mode: 0644]

index c58594602436b1570af2746bf7602e9260c23183..16abb96fd8e3082751ced79356dbecd7c6e9dfdc 100644 (file)
        * cp/parser.c (cp_parser_lambda_expression): Save/reset/restore
        auto_is_implicit_function_template_parm_p around lambda body.
 
+       PR c++/59638
+       * cp/parser.c (cp_parser_init_declarator): Undo fully implicit
+       template parameter list when declarator is not a function.
+
 2014-01-03  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/58950
index 6668f2ce5c02c306fd6b8969cf7edeac9b11196c..8c615200e54626b422f1398b1921df47c7c16121 100644 (file)
@@ -16780,6 +16780,15 @@ cp_parser_init_declarator (cp_parser* parser,
       warning (OPT_Wattributes,
               "attributes after parenthesized initializer ignored");
 
+  /* A non-template declaration involving a function parameter list containing
+     an implicit template parameter will have been made into a template.  If it
+     turns out that the resulting declaration is not an actual function then
+     finish the template declaration here.  An error message will already have
+     been issued.  */
+  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)
index 036b91adf4a68a8ea9394cae79ea4a6807b5731b..80113abfdecfffd97bf1fa991ffaf4d118481a39 100644 (file)
@@ -3,9 +3,11 @@
        PR c++/59635
        PR c++/59636
        PR c++/59629
+       PR c++/59638
        * g++.dg/cpp1y/pr59635.C: New testcase.
        * g++.dg/cpp1y/pr59636.C: New testcase.
        * g++.dg/cpp1y/pr59629.C: New testcase.
+       * g++.dg/cpp1y/pr59638.C: New testcase.
 
 2014-01-06  Martin Jambor  <mjambor@suse.cz>
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59638.C b/gcc/testsuite/g++.dg/cpp1y/pr59638.C
new file mode 100644 (file)
index 0000000..cd9dcdf
--- /dev/null
@@ -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;
+};