From: Jason Merrill Date: Thu, 20 Oct 2011 19:13:51 +0000 (-0400) Subject: re PR c++/41449 (Partial aggregate initialization not cleaned up on exception) X-Git-Tag: releases/gcc-4.7.0~2936 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76187e874a402294a0d34fc982da0b279f1ad2a9;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a32a7b9fca0d..df7e1bcf05c1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-10-20 Jason Merrill + + PR c++/41449 + * typeck2.c (split_nonconstant_init_1): Handle EH cleanup of + initialized subobjects. + 2011-10-19 Paolo Carlini PR c++/13657 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3accab621333..580f6690b29d 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 e8a6fca2c7b8..00e95e0308f6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-10-20 Jason Merrill + + PR c++/41449 + * g++.dg/eh/partial1.C: New. + 2011-10-20 Richard Henderson * 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 000000000000..db731770c2bf --- /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 (); +}