From: Jason Merrill Date: Tue, 13 Mar 2018 15:55:07 +0000 (-0400) Subject: PR c++/84798 - ICE with auto in abstract function declarator. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=426c1e2ec7b42902a80a20cb3965a69061b8345b;p=gcc.git PR c++/84798 - ICE with auto in abstract function declarator. * parser.c (cp_parser_parameter_declaration_clause): Check parser->default_arg_ok_p. From-SVN: r258493 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b5f0c36663..d480c1bafba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-13 Jason Merrill + + PR c++/84798 - ICE with auto in abstract function declarator. + * parser.c (cp_parser_parameter_declaration_clause): Check + parser->default_arg_ok_p. + 2018-03-13 Jakub Jelinek PR c++/84808 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index cdc62388973..8e8ebceb0d5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21198,7 +21198,10 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) if (!processing_specialization && !processing_template_parmlist - && !processing_explicit_instantiation) + && !processing_explicit_instantiation + /* default_arg_ok_p tracks whether this is a parameter-clause for an + actual function or a random abstract declarator. */ + && parser->default_arg_ok_p) if (!current_function_decl || (current_class_type && LAMBDA_TYPE_P (current_class_type))) parser->auto_is_implicit_function_template_parm_p = true; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto51.C b/gcc/testsuite/g++.dg/cpp0x/auto51.C new file mode 100644 index 00000000000..dfb08336b53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto51.C @@ -0,0 +1,9 @@ +// PR c++/84798 +// { dg-do compile { target c++11 } } + +template +struct S { + static constexpr T value = 0; +}; + +constexpr auto x = S::value; // { dg-error "auto" } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60393.C b/gcc/testsuite/g++.dg/cpp1y/pr60393.C index 27fe2b72296..2ae21ed1147 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60393.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60393.C @@ -1,8 +1,7 @@ // PR c++/60393 // { dg-do compile { target c++14 } } -// { dg-options "" } -void (*f)(auto) + 0; // { dg-error "expected" } +void (*f)(auto) + 0; // { dg-error "auto|expected" } struct A {