[dcl.dcl]/5 says that
enum { };
is ill-formed, and since r197742 we issue a pedwarn. However, the
pedwarn also fires for
enum { } x;
which is well-formed. So only warn when {} is followed by a ;. This
should be correct since you can't have "enum {}, <whatever>" -- that
produces "expected unqualified-id before ',' token".
PR c++/67048
gcc/cp/ChangeLog:
* parser.cc (cp_parser_enum_specifier): Warn about empty unnamed enum
only when it's followed by a semicolon.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/enum42.C: New test.
(cherry picked from commit
fd0d3e9121c5aa65150d242676be6bbdc8d4a92a)
/* If the next token is not '}', then there are some enumerators. */
else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE))
{
- if (is_unnamed && !scoped_enum_p)
+ if (is_unnamed && !scoped_enum_p
+ /* Don't warn for enum {} a; here. */
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_SEMICOLON))
pedwarn (type_start_token->location, OPT_Wpedantic,
"ISO C++ forbids empty unnamed enum");
}
--- /dev/null
+// PR c++/67048
+// { dg-do compile { target c++11 } }
+// { dg-options -Wpedantic }
+
+typedef enum {} X;
+enum {} x;
+enum {} y, z;