re PR c++/39028 (C++ front-end rejects "__label__" at the beginning of a block after "for" and "while")

PR c++/39028
	* parser.c (cp_parser_already_scoped_statement): Handle __label__
	declarations.

	* g++.dg/ext/label12.C: New test.

From-SVN: r143797
This commit is contained in:
Jakub Jelinek 2009-01-30 17:17:30 +01:00 committed by Jakub Jelinek
parent 1fae3e66da
commit ac9bc18b37
4 changed files with 54 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-01-30 Jakub Jelinek <jakub@redhat.com>
PR c++/39028
* parser.c (cp_parser_already_scoped_statement): Handle __label__
declarations.
2009-01-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/33465

View File

@ -7844,6 +7844,10 @@ cp_parser_already_scoped_statement (cp_parser* parser)
/* Avoid calling cp_parser_compound_statement, so that we
don't create a new scope. Do everything else by hand. */
cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>");
/* 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, NULL_TREE);
cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>");
}

View File

@ -1,3 +1,8 @@
2009-01-30 Jakub Jelinek <jakub@redhat.com>
PR c++/39028
* g++.dg/ext/label12.C: New test.
2009-01-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/33465

View File

@ -0,0 +1,39 @@
// PR c++/39028
// { dg-do compile }
// Origin: Stephan Springl <springl@bfw-online.de>
void
f ()
{
int i;
for (i = 0; i < 2; i++)
{
__label__ l;
goto l;
l:;
}
while (i++ < 5)
{
__label__ l;
goto l;
l:;
}
do
{
__label__ l;
goto l;
l:;
}
while (i++ < 8);
if (1)
{
__label__ l;
goto l;
l:;
}
{
__label__ l;
goto l;
l:;
}
}