https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84588
--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> ---
What I'm finishing testing:
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 260280)
+++ cp/parser.c (working copy)
@@ -21308,7 +21308,7 @@ cp_parser_parameter_declaration_list (cp_parser* p
while (true)
{
cp_parameter_declarator *parameter;
- tree decl = error_mark_node;
+ tree decl;
bool parenthesized_p = false;
/* Parse the parameter. */
@@ -21316,21 +21316,22 @@ cp_parser_parameter_declaration_list (cp_parser* p
= cp_parser_parameter_declaration (parser,
/*template_parm_p=*/false,
&parenthesized_p);
+ if (!parameter)
+ {
+ *is_error = true;
+ parameters = error_mark_node;
+ break;
+ }
/* We don't know yet if the enclosing context is deprecated, so wait
and warn in grokparms if appropriate. */
deprecated_state = DEPRECATED_SUPPRESS;
- if (parameter)
- {
- decl = grokdeclarator (parameter->declarator,
- ¶meter->decl_specifiers,
- PARM,
- parameter->default_argument != NULL_TREE,
- ¶meter->decl_specifiers.attributes);
- if (decl != error_mark_node && parameter->loc != UNKNOWN_LOCATION)
- DECL_SOURCE_LOCATION (decl) = parameter->loc;
- }
+ decl = grokdeclarator (parameter->declarator,
+ ¶meter->decl_specifiers,
+ PARM,
+ parameter->default_argument != NULL_TREE,
+ ¶meter->decl_specifiers.attributes);
deprecated_state = DEPRECATED_NORMAL;
@@ -21340,9 +21341,14 @@ cp_parser_parameter_declaration_list (cp_parser* p
{
*is_error = true;
parameters = error_mark_node;
+ if (parser->fully_implicit_function_template_p)
+ abort_fully_implicit_template (parser);
break;
}
+ if (parameter->loc != UNKNOWN_LOCATION)
+ DECL_SOURCE_LOCATION (decl) = parameter->loc;
+
if (parameter->decl_specifiers.attributes)
cplus_decl_attributes (&decl,
parameter->decl_specifiers.attributes,
Index: testsuite/g++.dg/cpp1y/pr84588.C
===================================================================
--- testsuite/g++.dg/cpp1y/pr84588.C (nonexistent)
+++ testsuite/g++.dg/cpp1y/pr84588.C (working copy)
@@ -0,0 +1,10 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-w" }
+
+struct a {
+ void b() {}
+ void c(auto = [] {
+ if (a a(int auto){}) // { dg-error "two or more data types" }
+ ;
+ }) {}
+};