OSDN Git Service

PR c++/39028
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Jan 2009 16:17:30 +0000 (16:17 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Jan 2009 16:17:30 +0000 (16:17 +0000)
* parser.c (cp_parser_already_scoped_statement): Handle __label__
declarations.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143797 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/label12.C [new file with mode: 0644]

index 7595491..f48474c 100644 (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
index 5baf5f5..5be2318 100644 (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, "%<}%>");
     }
index ff88ca9..c43d9c0 100644 (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
diff --git a/gcc/testsuite/g++.dg/ext/label12.C b/gcc/testsuite/g++.dg/ext/label12.C
new file mode 100644 (file)
index 0000000..2585318
--- /dev/null
@@ -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:;
+  }
+}