[Bug c/107164] No pedantic warning for declaration just referring to a previously-declared enum type

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 18 23:26:37 GMT 2022


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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:

https://gcc.gnu.org/g:f5f1d92fe2e1d75c3fae34497929a1965af704ae

commit r13-3366-gf5f1d92fe2e1d75c3fae34497929a1965af704ae
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Oct 18 23:25:47 2022 +0000

    c: Diagnose "enum tag;" after definition [PR107164]

    As noted in bug 101764, a declaration "enum tag;" is invalid in
    standard C after a definition, as well as when no definition is
    visible; we had a pedwarn-if-pedantic for the forward declaration
    case, but were missing one for the other case.  Add that missing
    diagnostic (if pedantic only).

    (These diagnostics will need to be appropriately conditioned when
    support is added for C2x enums with fixed underlying type, since "enum
    tag : type;" is OK both before and after a definition.)

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

            PR c/107164

    gcc/c/
            * c-decl.cc (shadow_tag_warned): If pedantic, diagnose "enum tag;"
            with previous declaration visible.

    gcc/testsuite/
            * gcc.dg/c99-tag-4.c, gcc.dg/c99-tag-5.c, gcc.dg/c99-tag-6.c: New
            tests.


More information about the Gcc-bugs mailing list