https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107164
Bug ID: 107164
Summary: No pedantic warning for declaration just referring to
a previously-declared enum type
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: stephenheumann at gmail dot com
Target Milestone: ---
gcc -std=c17 -pedantic accepts this without any diagnostics:
enum E {a,b,c};
enum E;
C17 section 6.7.2.3 p9 says that an "enum identifier" type specifier using a
tag with an existing declaration visible "specifies the same type as that other
declaration, and does not redeclare the tag". Accordingly, the second line
above does not declare a declarator, a tag, or the members of an enumeration,
and so it violates the constraint in C17 section 6.7 p2.
(The relevant standard text is basically the same from C99 through draft C23.
C90 is less explicit, but I think is intended to behave the same.)
This should at least give a pedantic warning. Perhaps it could be an
always-enabled warning, but I'm not sure if code like the above is supposed to
be allowed as a GCC extension.