diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index ee69934c20ff8a7c2e9872bdc866c13d1329a32e..a5cbb3e896fc210d39d99be9f5c039f9cc1cd3dc 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -21012,7 +21012,9 @@ cp_parser_enum_specifier (cp_parser* parser) /* 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"); } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum42.C b/gcc/testsuite/g++.dg/cpp0x/enum42.C new file mode 100644 index 0000000000000000000000000000000000000000..05b372a1947db9c106c63910fd767dd63b14947e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum42.C @@ -0,0 +1,7 @@ +// PR c++/67048 +// { dg-do compile { target c++11 } } +// { dg-options -Wpedantic } + +typedef enum {} X; +enum {} x; +enum {} y, z;