+2015-09-02 Marek Polacek <polacek@redhat.com>
+
+ PR c/67432
+ * c-parser.c (c_parser_enum_specifier): Give a better error for
+ an empty enum.
+
2015-08-18 Trevor Saunders <tbsaunde@tbsaunde.org>
* c-aux-info.c, c-parser.c, c-tree.h: Remove useless typedefs.
location_t decl_loc, value_loc;
if (c_parser_next_token_is_not (parser, CPP_NAME))
{
- c_parser_error (parser, "expected identifier");
+ /* Give a nicer error for "enum {}". */
+ if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE)
+ && !parser->error)
+ {
+ error_at (c_parser_peek_token (parser)->location,
+ "empty enum is invalid");
+ parser->error = true;
+ }
+ else
+ c_parser_error (parser, "expected identifier");
c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
values = error_mark_node;
break;
+2015-09-02 Marek Polacek <polacek@redhat.com>
+
+ PR c/67432
+ * gcc.dg/pr67432.c: New test.
+
2015-09-02 Christophe Lyon <christophe.lyon@linaro.org>
* lib/target-supports.exp (clear_effective_target_cache): New.
--- /dev/null
+/* PR c/67432 */
+/* { dg-do compile } */
+
+enum {}; /* { dg-error "empty enum is invalid" } */
+enum E {}; /* { dg-error "empty enum is invalid" } */
+enum F {} e; /* { dg-error "empty enum is invalid" } */