re PR c++/27951 (ICE with invalid anonymous union)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Mon, 12 Jun 2006 20:50:53 +0000 (20:50 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Mon, 12 Jun 2006 20:50:53 +0000 (20:50 +0000)
PR c++/27951
* decl2.c (finish_anon_union): Return early if build_anon_union_vars
fails.

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

From-SVN: r114577

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

index 3dc8225acefd1dee915aaad83a6d698d69d5b4a5..b1ed4f08446e78b1e07eb1c7f722052e3a02f979 100644 (file)
@@ -1,3 +1,9 @@
+2006-06-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27951
+       * decl2.c (finish_anon_union): Return early if build_anon_union_vars
+       fails.
+
 2006-06-12  Roger Sayle  <roger@eyesopen.com>
 
        PR c++/21210
index a30fed3064fa9ab48994fd5fcdbd4953b10d2235..49e320cfd1c13f8cd152b09990b4cc0e1d58d58c 100644 (file)
@@ -1109,6 +1109,8 @@ finish_anon_union (tree anon_union_decl)
     }
 
   main_decl = build_anon_union_vars (type, anon_union_decl);
+  if (main_decl == error_mark_node)
+    return;
   if (main_decl == NULL_TREE)
     {
       warning (0, "anonymous union with no members");
index 8e5d2c0be09968885337b3c80563f9b6e472d9f5..b43e5191ccb8b3f7a6898537b3f258b762e59753 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/27951
+       * g++.dg/other/anon4.C: New test.
+
 2006-06-12  Roger Sayle  <roger@eyesopen.com>
 
        PR c++/21210
diff --git a/gcc/testsuite/g++.dg/other/anon4.C b/gcc/testsuite/g++.dg/other/anon4.C
new file mode 100644 (file)
index 0000000..571f4ae
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/27951
+// { dg-do compile }
+
+void foo()
+{
+    int i;             // { dg-error "previously" }
+    union { int i; };  // { dg-error "redeclaration" }
+}