aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-10-20 15:13:51 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-10-20 15:13:51 -0400
commit76187e874a402294a0d34fc982da0b279f1ad2a9 (patch)
tree484117a5122d349a2fcd02304ec0dde61772dd4d
parent5dea5b2a34ca9f7feb347721f8817007e082d391 (diff)
downloadgcc-76187e874a402294a0d34fc982da0b279f1ad2a9.zip
gcc-76187e874a402294a0d34fc982da0b279f1ad2a9.tar.gz
gcc-76187e874a402294a0d34fc982da0b279f1ad2a9.tar.bz2
re PR c++/41449 (Partial aggregate initialization not cleaned up on exception)
PR c++/41449 * typeck2.c (split_nonconstant_init_1): Handle EH cleanup of initialized subobjects. From-SVN: r180267
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck2.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/eh/partial1.C37
4 files changed, 55 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a32a7b9..df7e1bc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 3accab6..580f669 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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++;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e8a6fca..00e95e0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..db73177
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/partial1.C
@@ -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 ();
+}