diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-04-11 09:01:24 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-04-11 09:01:24 +0000 |
commit | f06a1142fa0a3b361bcd9e4af5fbf84e78d75a37 (patch) | |
tree | 1183eeebd02180a92d25ccaf157c4b9095ebc7db /gcc/cp | |
parent | d07458be3e41c069c0eaf627a371ac7d297c782d (diff) | |
download | gcc-f06a1142fa0a3b361bcd9e4af5fbf84e78d75a37.zip gcc-f06a1142fa0a3b361bcd9e4af5fbf84e78d75a37.tar.gz gcc-f06a1142fa0a3b361bcd9e4af5fbf84e78d75a37.tar.bz2 |
re PR c++/54216 (Missing diagnostic for ill-formed anonymous enum declarations)
/cp
2013-04-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54216
* parser.c (cp_parser_enum_specifier): Check for empty
anonymous enums and anonymous scoped enums.
/testsuite
2013-04-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54216
* g++.dg/cpp0x/enum26.C: New.
* g++.old-deja/g++.pt/mangle1.C: Adjust.
From-SVN: r197742
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 767b2c3..8d0f6c1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-04-11 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54216 + * parser.c (cp_parser_enum_specifier): Check for empty + anonymous enums and anonymous scoped enums. + 2013-04-10 Jakub Jelinek <jakub@redhat.com> PR c++/56895 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 856dc9a..e015c4f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14750,6 +14750,9 @@ cp_parser_enum_specifier (cp_parser* parser) { identifier = make_anon_name (); is_anonymous = true; + if (scoped_enum_p) + error_at (type_start_token->location, + "anonymous scoped enum is not allowed"); } } pop_deferring_access_checks (); @@ -14897,7 +14900,13 @@ cp_parser_enum_specifier (cp_parser* parser) if (type == error_mark_node) cp_parser_skip_to_end_of_block_or_statement (parser); /* If the next token is not '}', then there are some enumerators. */ - else if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_BRACE)) + else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE)) + { + if (is_anonymous && !scoped_enum_p) + pedwarn (type_start_token->location, OPT_Wpedantic, + "ISO C++ forbids empty anonymous enum"); + } + else cp_parser_enumerator_list (parser, type); /* Consume the final '}'. */ |