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

2022-10-18 Thread jsm28 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107164

Joseph S. Myers  changed:

   What|Removed |Added

   Target Milestone|--- |13.0
 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Joseph S. Myers  ---
Fixed for GCC 13.

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

2022-10-18 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107164

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Joseph Myers :

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

commit r13-3366-gf5f1d92fe2e1d75c3fae34497929a1965af704ae
Author: Joseph Myers 
Date:   Tue Oct 18 23:25:47 2022 +

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.

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

2022-10-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107164

--- Comment #1 from Andrew Pinski  ---
clang says it is a GCC extension:
:2:6: warning: redeclaration of already-defined enum 'E' is a GNU
extension [-Wgnu-redeclared-enum]
enum E;
 ^
:1:6: note: previous definition is here
enum E {a,b,c};
 ^

GCC does have a forward declaration extension for enum types so it makes sense
to allow this as an extension too.

That is:
```
enum E;
enum E {a,b,c};
```

(which GCC does have a pedantic diagnostic about).