re PR c++/48537 (C++0x: ICE using union with non-trivial member)
authorJason Merrill <jason@redhat.com>
Mon, 18 Apr 2011 22:40:43 +0000 (18:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 18 Apr 2011 22:40:43 +0000 (18:40 -0400)
PR c++/48537
* init.c (build_value_init): Handle UNION_TYPE the same.

From-SVN: r172678

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/union4.C [new file with mode: 0644]

index e7d75e881fe30287396d26f2064057f2f6c0fb1e..cf21fd64a55e8475e883e0e2467350817858a7d3 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-18  Jason Merrill  <jason@redhat.com>
+
+       PR c++/48537
+       * init.c (build_value_init): Handle UNION_TYPE the same.
+
 2011-04-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/48632
index 3280d9b5d0dc221dd089496ab8ad045270ea5902..04d2bb2ab2f01cecffb70a6a13de3a3761f90557 100644 (file)
@@ -343,7 +343,7 @@ build_value_init (tree type, tsubst_flags_t complain)
                                      NULL, type, LOOKUP_NORMAL,
                                      complain),
           complain);
-      else if (TREE_CODE (type) != UNION_TYPE && TYPE_NEEDS_CONSTRUCTING (type))
+      else if (TYPE_NEEDS_CONSTRUCTING (type))
        {
          /* This is a class that needs constructing, but doesn't have
             a user-provided constructor.  So we need to zero-initialize
index 96fb5c5ace8814d9da1cd1e54d633fe2cc397464..b8e89094452642629121edff232d13f5b672f5e5 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-18  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/union4.C: New.
+
 2011-04-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/48661
diff --git a/gcc/testsuite/g++.dg/cpp0x/union4.C b/gcc/testsuite/g++.dg/cpp0x/union4.C
new file mode 100644 (file)
index 0000000..0705047
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/48537
+// { dg-options -std=c++0x }
+
+struct SFoo
+{
+  SFoo() =delete;              // { dg-error "declared" }
+};
+
+union UFoo                     // { dg-error "deleted" }
+{
+  SFoo foo;
+};
+
+int main()
+{
+  UFoo();                      // { dg-error "deleted" }
+}