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

--- 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:4b12cc841f32903c0d53dd973d703f0722b23cf3

commit r16-7476-g4b12cc841f32903c0d53dd973d703f0722b23cf3
Author: Marek Polacek <[email protected]>
Date:   Wed Feb 11 15:58:46 2026 -0500

    c++: missing type-only context [PR124045]

    [temp.res.general]/4.4.1 says that a decl-specifier of the
    decl-specifier-seq of a simple-declaration in namespace scope is
    a type-only context.  I think this goes back to P0634R3.  So

      [: ^^int :] a = 42;

    shouldn't require a 'typename' when in a namespace scope.

    The _diagnose_invalid_type_name change is so that we don't emit extra

      error: '<expression error>' in '...' does not name a type

    in concepts-return-req4.C, variadic74.C, and variadic-nested3.C.

            PR c++/124045

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_parse_and_diagnose_invalid_type_name): Also
            abort the tentative parse when id is error_mark_node.
            (cp_parser_simple_declaration): Set
CP_PARSER_FLAGS_TYPENAME_OPTIONAL
            when in a namespace scope.
            (cp_parser_single_declaration): Use cp_parser_flags instead of int.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/type1.C: Don't expect an error for a missing
typename
            in a namespace scope.

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

Reply via email to