From d1d5c77c405e06214323e29d1dc29b9771cb8ab9 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Tue, 29 Oct 2002 23:51:12 +0000 Subject: [PATCH] PR c++/8287 * decl.c (finish_destructor_body): Create the label to jump to when returning from a destructor here. (finish_function_body): Rather than here. * g++.dg/init/dtor2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_2-branch@58642 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 13 +++++-------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/init/dtor2.C | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/init/dtor2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eaba7552194..dd372fbee1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2002-10-29 Mark Mitchell + PR c++/8287 + * decl.c (finish_destructor_body): Create the label to jump to + when returning from a destructor here. + (finish_function_body): Rather than here. + * semantics.c (finish_alignof): Call complete_type before calling c_alignof. * decl2.c (build_expr_from_tree): Use diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1b139ffdafb..613766253f3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14112,6 +14112,10 @@ finish_destructor_body () { tree exprstmt; + /* Any return from a destructor will end up here; that way all base + and member cleanups will be run when the function returns. */ + add_stmt (build_stmt (LABEL_STMT, dtor_label)); + /* And perform cleanups for our bases and members. */ perform_base_cleanups (); @@ -14187,14 +14191,7 @@ void finish_function_body (compstmt) tree compstmt; { - if (processing_template_decl) - /* Do nothing now. */; - else if (DECL_DESTRUCTOR_P (current_function_decl)) - /* Any return from a destructor will end up here. Put it before the - cleanups so that an explicit return doesn't duplicate them. */ - add_stmt (build_stmt (LABEL_STMT, dtor_label)); - - /* Close the block; in a destructor, run the member cleanups. */ + /* Close the block. */ finish_compound_stmt (0, compstmt); if (processing_template_decl) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 592de43a953..4b1531d85f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2002-10-29 Mark Mitchell + PR c++/8287 + * g++.dg/init/dtor2.C: New test. + * g++.dg/template/alignof1.C: New test. 2002-10-28 Kaveh R. Ghazi diff --git a/gcc/testsuite/g++.dg/init/dtor2.C b/gcc/testsuite/g++.dg/init/dtor2.C new file mode 100644 index 00000000000..56c7cac914d --- /dev/null +++ b/gcc/testsuite/g++.dg/init/dtor2.C @@ -0,0 +1,28 @@ +// { dg-do run } + +extern "C" void abort (); + +struct A +{ + ~A(); +}; + +A::~A () { + abort (); +} + +struct B +{ + ~B(); +}; + +B::~B () { + if(true) return; + A a; +} + +int main() +{ + B b; + return 0; +} -- 2.11.4.GIT