From ee239d9146b1867efae233ef57cc282c0f197275 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 4 Nov 2011 17:38:16 +0000 Subject: [PATCH] * parser.c (cp_parser_enumerator_list): Do not warn about trailing commas in C++0x mode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180967 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 8 ++++++-- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/cpp0x/enum21a.C | 4 ++++ gcc/testsuite/g++.dg/cpp0x/enum21b.C | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/enum21a.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/enum21b.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 27c8b70..f984056 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2011-10-09 Magnus Fromreide + + * parser.c (cp_parser_enumerator_list): Do not warn about + trailing commas in C++0x mode. + 2011-11-04 Olivier Goffart Jason Merrill diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 811b2fa..2798eb7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14058,6 +14058,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, enum-specifier: enum-head { enumerator-list [opt] } + enum-head { enumerator-list , } [C++0x] enum-head: enum-key identifier [opt] enum-base [opt] @@ -14077,6 +14078,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, GNU Extensions: enum-key attributes[opt] identifier [opt] enum-base [opt] { enumerator-list [opt] }attributes[opt] + enum-key attributes[opt] identifier [opt] enum-base [opt] + { enumerator-list, }attributes[opt] [C++0x] Returns an ENUM_TYPE representing the enumeration, or NULL_TREE if the token stream isn't an enum-specifier after all. */ @@ -14416,8 +14419,9 @@ cp_parser_enumerator_list (cp_parser* parser, tree type) /* If the next token is a `}', there is a trailing comma. */ if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE)) { - if (!in_system_header) - pedwarn (input_location, OPT_pedantic, "comma at end of enumerator list"); + if (cxx_dialect < cxx0x && !in_system_header) + pedwarn (input_location, OPT_pedantic, + "comma at end of enumerator list"); break; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9bd248..d0e9423 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-10-09 Magnus Fromreide + + * g++.dg/cpp0x/enum21a.C: Test that enum x { y, } does + generate a pedwarn in c++98-mode. + * g++.dg/cpp0x/enum21b.C: Test that enum x { y, } + don't generate a pedwarn in c++0x-mode. + 2011-11-04 Olivier Goffart PR c++/50965 diff --git a/gcc/testsuite/g++.dg/cpp0x/enum21a.C b/gcc/testsuite/g++.dg/cpp0x/enum21a.C new file mode 100644 index 0000000..5526811 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum21a.C @@ -0,0 +1,4 @@ +// { dg-do compile } +// { dg-options "-pedantic -std=c++98" } + +enum x { y, }; // { dg-warning "comma at end of enumerator list" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum21b.C b/gcc/testsuite/g++.dg/cpp0x/enum21b.C new file mode 100644 index 0000000..4898912 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum21b.C @@ -0,0 +1,4 @@ +// { dg-do compile } +// { dg-options "-pedantic -std=c++0x" } + +enum x { y, }; -- 2.7.4