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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <[email protected]>:

https://gcc.gnu.org/g:84b4687eb445555c22db5ee5a71cb665ec7110d7

commit r16-4277-g84b4687eb445555c22db5ee5a71cb665ec7110d7
Author: Joseph Myers <[email protected]>
Date:   Tue Oct 7 23:04:54 2025 +0000

    c: Implement C2y handling of incomplete tentative definitions [PR26581]

    Before C2y, a tentative definition (file-scope, not extern, no
    initializer) with internal linkage and incomplete type was undefined
    behavior ("shall" outside Constraints violated).  In C2y, this has
    changed to a constraint violation if the type has not been completed
    by the end of the translation unit, and is valid if the type has been
    completed by the end of the translation unit.  This change originates
    from N3347 but the wording accepted into C2y was that from reflector
    message 26758.

    In GCC, the case of incomplete array types was a hard error with
    -pedantic, rather than a pedwarn, contrary to how -pedantic is
    supposed to behave; bug 26581 requested a change to allow this case
    with -pedantic (i.e. the change made in C2y).  For incomplete structs
    and unions, GCC only diagnoses them if the type remains incomplete at
    the end of the translation unit; bug 88727 (*not* fixed here) requests
    the case where the type gets completed should also be diagnosed as a
    quality of implementation matter (and that bug is still applicable for
    pre-C2y langauge versions and -Wc23-c2y-compat).

    Change the handling of arrays following C2y; the previous error
    becomes a pedwarn_c23 while there is a new error at the end of the
    translation unit if the type remains incomplete there in C2y mode.

    There is an ambiguity in the wording in C2y for the case where the
    type gets completed only in an inner scope; I've raised that in
    reflector message 34118.

    Bootstrapped with no regressions for x86_64-pc-linux-gnu.

            PR c/26581

    gcc/c/
            * c-decl.cc (c_finish_incomplete_decl): Give error for tentative
            definition of incomplete array for C2y with internal linkage.
            (finish_decl): Do not set DO_DEFAULT based on -pedantic.  Use
            pedwarn_c23 for missing array sizes for internal linkage.

    gcc/testsuite/
            * gcc.dg/c23-incomplete-2.c, gcc.dg/c23-incomplete-3.c,
            gcc.dg/c23-incomplete-4.c, gcc.dg/c2y-incomplete-4.c,
            gcc.dg/c2y-incomplete-5.c: New tests.
            * gcc.dg/c23-thread-local-2.c, gcc.dg/c2y-incomplete-1.c: Update
            expected errors.
  • [Bug c/88727] Diagnostics impro... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to