PR c++/41449
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Oct 2011 19:13:51 +0000 (19:13 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Oct 2011 19:13:51 +0000 (19:13 +0000)
* typeck2.c (split_nonconstant_init_1): Handle EH cleanup of
initialized subobjects.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180267 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/eh/partial1.C [new file with mode: 0644]

index a32a7b9..df7e1bc 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41449
+       * typeck2.c (split_nonconstant_init_1): Handle EH cleanup of
+       initialized subobjects.
+
 2011-10-19  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/13657
index 3accab6..580f669 100644 (file)
@@ -567,6 +567,13 @@ split_nonconstant_init_1 (tree dest, tree init)
              code = build2 (INIT_EXPR, inner_type, sub, value);
              code = build_stmt (input_location, EXPR_STMT, code);
              add_stmt (code);
+             if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (inner_type))
+               {
+                 code = (build_special_member_call
+                         (sub, complete_dtor_identifier, NULL, inner_type,
+                          LOOKUP_NORMAL, tf_warning_or_error));
+                 finish_eh_cleanup (code);
+               }
 
              num_split_elts++;
            }
index e8a6fca..00e95e0 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41449
+       * g++.dg/eh/partial1.C: New.
+
 2011-10-20  Richard Henderson  <rth@redhat.com>
 
        * gcc.target/i386/vperm-v2df.c, gcc.target/i386/vperm-v2di.c,
diff --git a/gcc/testsuite/g++.dg/eh/partial1.C b/gcc/testsuite/g++.dg/eh/partial1.C
new file mode 100644 (file)
index 0000000..db73177
--- /dev/null
@@ -0,0 +1,37 @@
+// PR c++/41449
+// { dg-do run }
+
+struct A
+{
+  A() {}
+  A(const A&) { throw 1; }
+};
+
+int bs;
+struct B
+{
+  B() { ++bs; }
+  B(const B&) { ++bs; }
+  ~B() { --bs; }
+};
+
+struct C
+{
+  B b1;
+  A a;
+  B b2;
+};
+
+int main()
+{
+  {
+    B b1, b2;
+    A a;
+
+    try {
+      C c = { b1, a, b2 };
+    } catch (...) {}
+  }
+  if (bs != 0)
+    __builtin_abort ();
+}