]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/41449 (Partial aggregate initialization not cleaned up on exception)
authorJason Merrill <jason@redhat.com>
Thu, 20 Oct 2011 19:13:51 +0000 (15:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 20 Oct 2011 19:13:51 +0000 (15:13 -0400)
PR c++/41449
* typeck2.c (split_nonconstant_init_1): Handle EH cleanup of
initialized subobjects.

From-SVN: r180267

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

index a32a7b9fca0db8ad26aa8083f2399b5a746236c8..df7e1bcf05c1b0c680747fc44a2ed3fb534155b7 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 3accab621333011b63ad5a9480c89990381ed87a..580f6690b29d935f19517097039fb09b0b1cca35 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 e8a6fca2c7b8bb2e153ef4c9d882f41bca481ab7..00e95e0308f67f209c0ee0703c9a5cb09b2ed7ca 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 ();
+}