]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/27820 (ICE with duplicate label)
authorLee Millward <lee.millward@gmail.com>
Fri, 7 Jul 2006 17:57:12 +0000 (17:57 +0000)
committerLee Millward <lmillward@gcc.gnu.org>
Fri, 7 Jul 2006 17:57:12 +0000 (17:57 +0000)
PR c++/27820
* decl.c (define_label): Return error_mark_node on error.
* semantics.c (finish_label_stmt): Don't call
add_stmt for invalid labels.

* g++.dg/other/label1.C: New test.

Co-Authored-By: Andrew Pinski <pinskia@gmail.com>
From-SVN: r115265

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/label1.C [new file with mode: 0644]

index b7929640c01434fe1a39e28843427197612c9b77..d499bfdadd0496cf4b65fb341ce8dc85d57c0727 100644 (file)
@@ -1,3 +1,11 @@
+2006-06-29  Lee Millward  <lee.millward@gmail.com>
+           Andrew Pinski  <pinskia@gmail.com>
+
+       PR c++/27820
+       * decl.c (define_label): Return error_mark_node on error.
+       * semantics.c (finish_label_stmt): Don't call
+       add_stmt for invalid labels.
+       
 2006-07-06  Jason Merrill  <jason@redhat.com>
 
        PR c++/28279
index 49d192024729a10b23f66d8895a6237c9bf136e3..1d5be58e09f401457279a75b7d39d80bee7c36b7 100644 (file)
@@ -2543,7 +2543,10 @@ define_label (location_t location, tree name)
     pedwarn ("label named wchar_t");
 
   if (DECL_INITIAL (decl) != NULL_TREE)
-    error ("duplicate label %qD", decl);
+    {
+      error ("duplicate label %qD", decl);
+      POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
+    }
   else
     {
       struct named_label_use_entry *use;
index c5b3fbb0f627457cea3319610c9ac6f0d1d9cfc7..9ecace6806a0b6600b37eadc9fcf7edb89de659b 100644 (file)
@@ -1293,6 +1293,10 @@ tree
 finish_label_stmt (tree name)
 {
   tree decl = define_label (input_location, name);
+
+  if (decl  == error_mark_node)
+    return error_mark_node;
+
   return add_stmt (build_stmt (LABEL_EXPR, decl));
 }
 
index 6ce58b2447280125a8d37c1e318a4f9f9bb6cd55..9203c1566daa077fe89ca605a3565d9a210aac32 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-07  Lee Millward  <lee.millward@gmail.com>
+
+       PR c++/27820
+       * g++.dg/other/label1.C: New test.
+       
 2006-07-07   Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/28268
diff --git a/gcc/testsuite/g++.dg/other/label1.C b/gcc/testsuite/g++.dg/other/label1.C
new file mode 100644 (file)
index 0000000..74572dc
--- /dev/null
@@ -0,0 +1,7 @@
+//PR c++/27820
+
+void foo()
+{
+    L: L: ; // { dg-error "duplicate label" }
+}
+
This page took 0.136969 seconds and 5 git commands to generate.