+2007-12-04 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ * c-parser (c_parser_statement_after_labels): Move error from here...
+ (c_parser_label): ... to here. Check that the declaration is not
+ actually just another label.
+
2007-12-04 Richard Guenther <rguenther@suse.de>
PR middle-end/34334
}
}
if (label)
- SET_EXPR_LOCATION (label, loc1);
+ {
+ SET_EXPR_LOCATION (label, loc1);
+ if (c_parser_next_token_starts_declspecs (parser)
+ && !(c_parser_next_token_is (parser, CPP_NAME)
+ && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
+ {
+ error ("%Ha label can only be part of a statement and "
+ "a declaration is not a statement",
+ &c_parser_peek_token (parser)->location);
+ c_parser_declaration_or_fndef (parser, /*fndef_ok*/ false,
+ /*nested*/ true, /*empty_ok*/ false,
+ /*start_attr_ok*/ true);
+ }
+ }
}
/* Parse a statement (C90 6.6, C99 6.8).
break;
default:
expr_stmt:
- if (c_parser_next_token_starts_declspecs (parser))
- {
- error ("%Ha label can only be part of a statement and "
- "a declaration is not a statement",
- &c_parser_peek_token (parser)->location);
- c_parser_declaration_or_fndef (parser, /*fndef_ok*/ false,
- /*nested*/ true, /*empty_ok*/ false,
- /*start_attr_ok*/ true);
- return;
- }
stmt = c_finish_expr_stmt (c_parser_expression_conv (parser).value);
expect_semicolon:
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");