https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113802
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:3ecc5071797c4ceb6da67a6c2b2527a046091de2 commit r14-9384-g3ecc5071797c4ceb6da67a6c2b2527a046091de2 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Mar 8 09:11:57 2024 +0100 c++: Fix up parameter pack diagnostics on xobj vs. varargs functions [PR113802] The simple presence of ellipsis as next token after the parameter declaration doesn't imply it is a parameter pack, it sometimes is, e.g. if its type is a pack, but sometimes is not and in that case it acts the same as if the next tokens were , ... instead of just ... The xobj param cannot be a function parameter pack though treats both the declarator->parameter_pack_p and token->type == CPP_ELLIPSIS as sufficient conditions for the error. The conditions for CPP_ELLIPSIS are done a little bit later in the same function and complex enough that IMHO shouldn't be repeated, on the other side for the declarator->parameter_pack_p case we clear that flag for xobj params for error recovery reasons. This patch just moves the diagnostics later (after the CPP_ELLIPSIS handling) and changes the error recovery behavior by pretending the this specifier didn't appear if an error is reported. 2024-03-08 Jakub Jelinek <ja...@redhat.com> PR c++/113802 * parser.cc (cp_parser_parameter_declaration): Move the xobj_param_p pack diagnostics after ellipsis handling and if an error is reported, pretend this specifier didn't appear. Formatting fix. * g++.dg/cpp23/explicit-obj-diagnostics3.C (S0, S1, S2, S3, S4): Don't expect any diagnostics on f and fd member function templates, add similar templates with ...Selves instead of Selves as k and kd and expect diagnostics for those. Expect extra diagnostics in error recovery for g and gd member function templates.