aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-30 17:17:30 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-01-30 17:17:30 +0100
commitac9bc18b3732f27fafb2a318e6a0ad8439551d5e (patch)
tree62d2dbb7afa1069d4a60746f7316516e7c02f2fe /gcc
parent1fae3e66dac0f62eafa859d144d56c704536cf7a (diff)
downloadgcc-ac9bc18b3732f27fafb2a318e6a0ad8439551d5e.zip
gcc-ac9bc18b3732f27fafb2a318e6a0ad8439551d5e.tar.gz
gcc-ac9bc18b3732f27fafb2a318e6a0ad8439551d5e.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/label12.C39
4 files changed, 54 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7595491..f48474c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5baf5f5..5be2318 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 ff88ca9..c43d9c0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/ext/label12.C b/gcc/testsuite/g++.dg/ext/label12.C
new file mode 100644
index 0000000..2585318
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/label12.C
@@ -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:;
+ }
+}