https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113802
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org, | |waffl3x at protonmail dot com --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The problem is that as the comment says, when next token is ellipsis, it isn't at that point clear if it will be a parameter pack or the odd varargs case without , before ellipsis. I've tried --- gcc/cp/parser.cc.jj 2024-02-14 14:26:19.000000000 +0100 +++ gcc/cp/parser.cc 2024-02-15 11:07:01.706650134 +0100 @@ -25727,17 +25727,10 @@ cp_parser_parameter_declaration (cp_pars bool const xobj_param_p = decl_spec_seq_has_spec_p (&decl_specifiers, ds_this); - if (xobj_param_p - && ((declarator && declarator->parameter_pack_p) - || cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))) + bool diag_xobj_parameter_pack = false; + if (xobj_param_p && (declarator && declarator->parameter_pack_p)) { - location_t xobj_param - = make_location (decl_specifiers.locations[ds_this], - decl_spec_token_start->location, - input_location); - error_at (xobj_param, - "an explicit object parameter cannot " - "be a function parameter pack"); + diag_xobj_parameter_pack = true; /* Suppress errors that occur down the line. */ if (declarator) declarator->parameter_pack_p = false; @@ -25755,9 +25748,10 @@ cp_parser_parameter_declaration (cp_pars (INNERMOST_TEMPLATE_PARMS (current_template_parms)); if (latest_template_parm_idx != template_parm_idx) - decl_specifiers.type = convert_generic_types_to_packs - (decl_specifiers.type, - template_parm_idx, latest_template_parm_idx); + decl_specifiers.type + = convert_generic_types_to_packs (decl_specifiers.type, + template_parm_idx, + latest_template_parm_idx); } if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) @@ -25775,18 +25769,34 @@ cp_parser_parameter_declaration (cp_pars { /* Consume the `...'. */ cp_lexer_consume_token (parser->lexer); - maybe_warn_variadic_templates (); - - /* Build a pack expansion type */ - if (template_parm_p) - template_parameter_pack_p = true; - else if (declarator) - declarator->parameter_pack_p = true; + if (xobj_param_p) + diag_xobj_parameter_pack = true; else - decl_specifiers.type = make_pack_expansion (type); + { + maybe_warn_variadic_templates (); + + /* Build a pack expansion type */ + if (template_parm_p) + template_parameter_pack_p = true; + else if (declarator) + declarator->parameter_pack_p = true; + else + decl_specifiers.type = make_pack_expansion (type); + } } } + if (diag_xobj_parameter_pack) + { + location_t xobj_param + = make_location (decl_specifiers.locations[ds_this], + decl_spec_token_start->location, + input_location); + error_at (xobj_param, + "an explicit object parameter cannot " + "be a function parameter pack"); + } + /* The restriction on defining new types applies only to the type of the parameter, not to the default argument. */ parser->type_definition_forbidden_message = saved_message; and that causes FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 27) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 36) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 47) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 56) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 67) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 76) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 87) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 96) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 107) FAIL: g++.dg/cpp23/explicit-obj-diagnostics3.C -std=c++23 (test for errors, line 116) where presumably those lines are valid, not invalid, but I'm not sure and /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:32:22: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:41:23: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:52:23: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:61:24: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:72:24: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:81:25: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:92:29: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:101:30: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:112:30: error: parameter packs not expanded with '...': /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:121:31: error: parameter packs not expanded with '...': excess errors which are an undesirable side-effect. Ditto for -std=c++26.