http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54216

             Bug #: 54216
           Summary: Missing diagnostic for ill-formed anonymous enum
                    declarations
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: frankhb1...@gmail.com


G++(-pedantic-errors) wrongly accepts following non-conforming enumeration
declarations(in namespace scope or block scope) and no diagnostic output at
all:

enum {}; //-std=c++98 or -std=c++11

enum class {}; //-std=c++11

enum class { x }; //-std=c++11

According the standard, all of them are ill-formed:

(for the first declaration)
ISO C++98/03/11
7/3 ...
[Example:
enum { }; // ill-formed
typedef class { }; // ill-formed
—end example]

(for others)
ISO C++11
7.2/2 ... The optional identifier shall not be omitted in the declaration of a
scoped enumeration. ...

While clang++(trunk, also using -pedantic-errors) rejects them correctly:

(for the first declaration, -std=c++98 or -std=c++11)
error: declaration does not declare anything
      [-Werror,-Wmissing-declarations]
enum {};
^~~~

(for others, -std=c++11)
error: scoped enumeration requires a name
enum class { };
           ^
error: declaration does not declare anything
      [-Werror,-Wmissing-declarations]
enum class { };
^~~~
error: scoped enumeration requires a name
enum class { x };
           ^

Reply via email to