aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2015-09-02 21:00:38 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2015-09-02 21:00:38 +0000
commitd04ff41777d999fe5f387f46ec8b9cb22422c513 (patch)
tree3901f7d42cdbd8c3a98a30c77f0966011f7cd54d /gcc/c/c-parser.c
parentdb3015e9e3b5bd8bae0cf6c629f4f8333a01f855 (diff)
downloadgcc-d04ff41777d999fe5f387f46ec8b9cb22422c513.zip
gcc-d04ff41777d999fe5f387f46ec8b9cb22422c513.tar.gz
gcc-d04ff41777d999fe5f387f46ec8b9cb22422c513.tar.bz2
re PR c/67432 (Improve error message on empty enum)
PR c/67432 * c-parser.c (c_parser_enum_specifier): Give a better error for an empty enum. * gcc.dg/pr67432.c: New test. From-SVN: r227421
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 1a58798..11a2b0f 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -2555,7 +2555,16 @@ c_parser_enum_specifier (c_parser *parser)
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;