* 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 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; +}; -- 1.8.5.2