+2007-10-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/32121
+ * parser.c (cp_parser_compound_statement): Handle label-declarations
+ at the beginning of the compound statement.
+ (cp_parser_block_declaration): Issue diagnostics about __label__
+ not at the beginning of a block.
+
2007-10-11 Paolo Carlini <pcarlini@suse.de>
PR c++/33461
compound-statement:
{ statement-seq [opt] }
+ GNU extension:
+
+ compound-statement:
+ { label-declaration-seq [opt] statement-seq [opt] }
+
+ label-declaration-seq:
+ label-declaration
+ label-declaration-seq label-declaration
+
Returns a tree representing the statement. */
static tree
return error_mark_node;
/* Begin the compound-statement. */
compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0);
+ /* If the next keyword is `__label__' we have a label declaration. */
+ while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL))
+ cp_parser_label_declaration (parser);
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser, in_statement_expr);
/* Finish the compound-statement. */
block-declaration:
__extension__ block-declaration
- label-declaration
C++0x Extension:
cp_parser_using_declaration (parser,
/*access_declaration_p=*/false);
}
- /* If the next keyword is `__label__' we have a label declaration. */
+ /* If the next keyword is `__label__' we have a misplaced label
+ declaration. */
else if (token1->keyword == RID_LABEL)
{
- if (statement_p)
- cp_parser_commit_to_tentative_parse (parser);
- cp_parser_label_declaration (parser);
+ cp_lexer_consume_token (parser->lexer);
+ error ("%<__label__%> not at the beginning of a block");
+ cp_parser_skip_to_end_of_statement (parser);
+ /* If the next token is now a `;', consume it. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ cp_lexer_consume_token (parser->lexer);
}
/* If the next token is `static_assert' we have a static assertion. */
else if (token1->keyword == RID_STATIC_ASSERT)
+2007-10-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/32121
+ * g++.dg/ext/label4.C: Adjust error regexp.
+ * g++.dg/ext/label6.C: Adjust error regexp.
+ * g++.dg/ext/label7.C: New test.
+ * g++.dg/ext/label8.C: New test.
+ * g++.dg/ext/label9.C: New test.
+
2007-10-11 Kenneth Zadeck <zadeck@naturalbridge.com>
PR middle-end/33676