https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112482
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:1ae71269890f532a2bb06b84fc49f474c16e230d commit r14-6563-g1ae71269890f532a2bb06b84fc49f474c16e230d Author: Marek Polacek <pola...@redhat.com> Date: Thu Dec 14 12:01:21 2023 -0500 c++: fix parsing with auto(x) at block scope [PR112482] This is sort of like r14-5514, but at block scope. Consider struct A { A(int, int); }; void g (int a) { A bar(auto(a), 42); // not a fn decl } where we emit error: 'auto' parameter not permitted in this context which is bogus -- bar doesn't declare a function, so the auto is OK, but we don't know it till we've seen the second argument. The error comes from grokdeclarator invoked just after we've parsed the auto(a). A possible approach seems to be to delay the auto parameter checking and only check once we know we are indeed dealing with a function declaration. For tparms, we should still emit the error right away. PR c++/112482 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Do not issue the auto parameter error while tentatively parsing a function parameter. * parser.cc (cp_parser_parameter_declaration_clause): Check it here. gcc/testsuite/ChangeLog: * g++.dg/cpp23/auto-fncast15.C: New test.