OSDN Git Service

PR c++/48537
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Apr 2011 23:29:30 +0000 (23:29 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Apr 2011 23:29:30 +0000 (23:29 +0000)
* init.c (build_value_init): Handle UNION_TYPE the same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172679 138bc75d-0d04-0410-961f-82ee72b054a4

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

index c263c78..5b9eb2e 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 e1961c8..4798257 100644 (file)
@@ -343,7 +343,7 @@ build_value_init (tree type, tsubst_flags_t complain)
           build_special_member_call (NULL_TREE, complete_ctor_identifier,
                                      NULL, type, LOOKUP_NORMAL,
                                      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 8f71d86..e13ac42 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" }
+}