From: Jakub Jelinek Date: Fri, 30 Jan 2009 16:17:30 +0000 (+0100) Subject: re PR c++/39028 (C++ front-end rejects "__label__" at the beginning of a block after... X-Git-Tag: releases/gcc-4.4.0~692 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac9bc18b3732f27fafb2a318e6a0ad8439551d5e;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7595491e2d0a..f48474cfe3ab 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Jakub Jelinek + + PR c++/39028 + * parser.c (cp_parser_already_scoped_statement): Handle __label__ + declarations. + 2009-01-30 Paolo Carlini PR c++/33465 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5baf5f55196f..5be231881550 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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, "%<}%>"); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff88ca947666..c43d9c022d9f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-30 Jakub Jelinek + + PR c++/39028 + * g++.dg/ext/label12.C: New test. + 2009-01-30 Paolo Carlini PR c++/33465 diff --git a/gcc/testsuite/g++.dg/ext/label12.C b/gcc/testsuite/g++.dg/ext/label12.C new file mode 100644 index 000000000000..2585318b2538 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/label12.C @@ -0,0 +1,39 @@ +// PR c++/39028 +// { dg-do compile } +// Origin: Stephan Springl + +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:; + } +}