From 82d351a634a3a7838e7bf806760ef568e9f71810 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 13 Dec 2001 22:08:50 -0500 Subject: [PATCH] c-common.h (COMPOUND_STMT_BODY_BLOCK): New macro. * c-common.h (COMPOUND_STMT_BODY_BLOCK): New macro. Use cleanups to run base and member destructors. * init.c (push_base_cleanups): New function, split out from... (build_delete): ...here. Lose !TYPE_HAS_DESTRUCTOR code. * decl.c (finish_destructor_body): Move vbase destruction code to push_base_cleanups. (begin_function_body, finish_function_body): New fns. (finish_function): Move [cd]tor handling and call_poplevel to finish_function_body. (pushdecl): Skip the new level. * semantics.c (genrtl_try_block): Don't call end_protect_partials. (setup_vtbl_ptr): Call push_base_cleanups. * method.c (synthesize_method): Call {begin,end}_function_body. * pt.c (tsubst_expr): Handle COMPOUND_STMT_BODY_BLOCK. * cp-tree.h: Declare new fns. * parse.y (function_body, .begin_function_body): New nonterminals. (fndef, pending_inline, function_try_block): Use function_body. (ctor_initializer_opt, function_try_block): No longer has a value. (base_init): Remove .set_base_init token. (.set_base_init, compstmt_or_error): Remove. * Make-lang.in (parse.c): Expect two fewer s/r conflicts. From-SVN: r47988 --- gcc/testsuite/g++.dg/eh/dtor1.C | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gcc/testsuite/g++.dg/eh/dtor1.C diff --git a/gcc/testsuite/g++.dg/eh/dtor1.C b/gcc/testsuite/g++.dg/eh/dtor1.C new file mode 100644 index 0000000..c1c3ada --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/dtor1.C @@ -0,0 +1,33 @@ +// Test that a fully-constructed base is destroyed before transferring +// control to the handler of a function-try-block. + +// { dg-do run } + +int ad; +int r; + +struct A { + ~A() { ++ad; } +}; + +struct B: public A { + ~B(); +}; + +B::~B () +try + { + throw 1; + } +catch (...) + { + if (!ad) + r = 1; + return; + } + +int main () +{ + { B b; } + return r; +} -- 2.7.4