re PR c++/44625 (ICE after error: anonymous struct not inside named type)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 23 Jun 2011 16:58:28 +0000 (16:58 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 23 Jun 2011 16:58:28 +0000 (16:58 +0000)
/cp
2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/44625
* decl2.c (build_anon_union_vars): Early return error_mark_node
for a nested anonymous struct.

/testsuite
2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/44625
* g++.dg/template/crash107.C: New.
* g++.dg/template/error17.C: Adjust.

From-SVN: r175344

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

index 23aaac1c4f985d33ded2123a1b9406dc64d8b3b9..c7e39be0946b2f4c94dfc4ab5bbec32959797b4c 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/44625
+       * decl2.c (build_anon_union_vars): Early return error_mark_node
+       for a nested anonymous struct.
+
 2011-06-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/49507
index 9e5a2297190383bd9ed962a1f434bfd0cfd46cfa..8cd51c28a2c652cd9a7c87ac84569bd4246cbb16 100644 (file)
@@ -1327,7 +1327,10 @@ build_anon_union_vars (tree type, tree object)
   /* Rather than write the code to handle the non-union case,
      just give an error.  */
   if (TREE_CODE (type) != UNION_TYPE)
-    error ("anonymous struct not inside named type");
+    {
+      error ("anonymous struct not inside named type");
+      return error_mark_node;
+    }
 
   for (field = TYPE_FIELDS (type);
        field != NULL_TREE;
index 8f6b625c3b383deadd065c306b094d628ca9e550..26f40f0c79bf12d00de9abe9ee70e04436784c1d 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-23  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/44625
+       * g++.dg/template/crash107.C: New.
+       * g++.dg/template/error17.C: Adjust.
+
 2011-06-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/49507
diff --git a/gcc/testsuite/g++.dg/template/crash107.C b/gcc/testsuite/g++.dg/template/crash107.C
new file mode 100644 (file)
index 0000000..cd64c37
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/44625
+// { dg-do compile }
+// { dg-options "" }
+
+template<typename FP_> struct Vec { // { dg-message "note" }
+    Vec& operator^=(Vec& rhs)     {
+        union {
+            struct {FP_ x,y,z;};
+        }; // { dg-error "anonymous struct" }
+        X = y*rhs.z() - z*rhs.y(); // { dg-error "not declared|no member" }
+    }
+    Vec& operator^(Vec& rhs) {
+        return Vec(*this)^=rhs; // { dg-message "required" }
+    }
+};
+Vec<double> v(3,4,12); // { dg-error "no matching" }
+// { dg-message "note" { target *-*-* } 16 }
+Vec<double> V(12,4,3);  // { dg-error "no matching" }
+// { dg-message "note" { target *-*-* } 18 }
+Vec<double> c = v^V;   // { dg-message "required" }
index f34234da79f621d00a9708c9e3620fd173f68337..10c8b824ae5ac3e4843ce5c3c8221c7ef6f00277 100644 (file)
@@ -6,5 +6,4 @@ foo()
 {
   union { struct { }; }; // { dg-error "prohibits anonymous struct" "anon" }
   // { dg-error "not inside" "not inside" { target *-*-* } 7 }
-  // { dg-warning "no members" "no members" { target *-*-* } 7 }
 }