From aaa15a0d0823654d69cb9d4d751a0ecf3ed6ee49 Mon Sep 17 00:00:00 2001 From: Adam Butcher Date: Mon, 6 Jan 2014 18:22:48 +0000 Subject: re PR c++/59638 ([c++1y] ICE with pointer to function that has auto as parameter) 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 | 4 ++++ gcc/cp/parser.c | 9 +++++++++ gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/cpp1y/pr59638.C | 16 ++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59638.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c585946..16abb96 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -12,6 +12,10 @@ * 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 PR c++/58950 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6668f2c..8c61520 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 036b91a..80113ab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 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; +}; -- cgit v1.1