===================================================================
@@ -3255,6 +3255,10 @@
"user-defined literals "
"only available with -std=c++0x or -std=gnu++0x");
break;
+ case CPP0X_ENUM_TRAILING_COMMA:
+ pedwarn (input_location, OPT_pedantic,
+ "comma at end of enumerator list");
+ break;
default:
gcc_unreachable ();
}
===================================================================
@@ -14058,6 +14058,7 @@
enum-specifier:
enum-head { enumerator-list [opt] }
+ enum-head { enumerator-list , } [C++11]
enum-head:
enum-key identifier [opt] enum-base [opt]
@@ -14077,6 +14078,8 @@
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++11]
Returns an ENUM_TYPE representing the enumeration, or NULL_TREE
if the token stream isn't an enum-specifier after all. */
@@ -14416,8 +14419,7 @@
/* 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");
+ maybe_warn_cpp0x(CPP0X_ENUM_TRAILING_COMMA);
break;
}
}
===================================================================
@@ -402,7 +402,9 @@
/* non-static data member initializers */
CPP0X_NSDMI,
/* user defined literals */
- CPP0X_USER_DEFINED_LITERALS
+ CPP0X_USER_DEFINED_LITERALS,
+ /* trailing comma in enumerations */
+ CPP0X_ENUM_TRAILING_COMMA
} cpp0x_warn_str;
/* The various kinds of operation used by composite_pointer_type. */
===================================================================
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-pedantic-errors -std=c++98" }
+
+enum x { y, }; // { dg-error "comma at end of enumerator list" }
===================================================================
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-pedantic-errors -std=c++0x" }
+
+enum x { y, };