https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127780

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <[email protected]>:

https://gcc.gnu.org/g:088d18f1833e84cd5153cdae7687331edb56e948

commit r17-5099-g088d18f1833e84cd5153cdae7687331edb56e948
Author: Marek Polacek <[email protected]>
Date:   Fri Oct 9 16:21:46 2026 -0400

    c++: using in init-stmt followed by colon accepted [PR127780]

    We accept the stray ':' in

      if (using T = int; : x)

    because we're fooled into thinking it's a range-for.  Fix it the
    obvious way: cp_parser_alias_declaration already consumes the ';',
    so a following ':' can't belong to a range-for declaration.

    Also, it's better to point at the location of the 'using' than at whatever
    follows it.

            PR c++/127780

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_init_statement): Use the location of
            'using' in the C++23 pedwarn.  Only consume the ':' if
            expect_semicolon_p.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp23/init-stmt3.C: New test.
            * g++.dg/cpp23/init-stmt4.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to