public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107164] New: No pedantic warning for declaration just referring to a previously-declared enum type
@ 2022-10-05 21:57 stephenheumann at gmail dot com
  2022-10-05 22:05 ` [Bug c/107164] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stephenheumann at gmail dot com @ 2022-10-05 21:57 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-18 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 21:57 [Bug c/107164] New: No pedantic warning for declaration just referring to a previously-declared enum type stephenheumann at gmail dot com
2022-10-05 22:05 ` [Bug c/107164] " pinskia at gcc dot gnu.org
2022-10-18 23:26 ` cvs-commit at gcc dot gnu.org
2022-10-18 23:27 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).