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

--- Comment #7 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:ad2908ed4ec5eff3cad3fd142cde5c1fac4788e9

commit r15-7719-gad2908ed4ec5eff3cad3fd142cde5c1fac4788e9
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Feb 26 19:31:08 2025 +0100

    c: Assorted fixes for flexible array members in unions [PR119001]

    r15-209 allowed flexible array members inside of unions, but as the
    following testcase shows, not everything has been adjusted for that.
    Unlike structures, in unions flexible array member (as an extension)
    can be any of the members, not just the last one, as in union all
    members are effectively last.
    The first hunk is about an ICE on the initialization of the FAM
    in union which is not the last FIELD_DECL with a string literal,
    the second hunk just formatting fix, third hunk fixes a bug in which
    we were just throwing away the initializers (except for with string
literal)
    of FAMs in unions which aren't the last FIELD_DECL, and the last hunk
    is to diagnose FAM errors in unions the same as for structures, in
    particular trying to initialize a FAM with non-constant or initialization
    in nested context.

    2025-02-26  Jakub Jelinek  <ja...@redhat.com>

            PR c/119001
    gcc/
            * varasm.cc (output_constructor_regular_field): Don't fail
            assertion if next is non-NULL and FIELD_DECL if
            TREE_CODE (local->type) is UNION_TYPE.
    gcc/c/
            * c-typeck.cc (pop_init_level): Don't clear constructor_type
            if DECL_CHAIN of constructor_fields is NULL but p->type is
UNION_TYPE.
            Formatting fix.
            (process_init_element): Diagnose non-static initialization of
flexible
            array member in union or FAM in union initialization in nested
context.
    gcc/testsuite/
            * gcc.dg/pr119001-1.c: New test.
            * gcc.dg/pr119001-2.c: New test.

Reply via email to