From 3ec8c2a1cf762f634aa5516ee83f7bf95ef04b54 Mon Sep 17 00:00:00 2001 From: rth Date: Tue, 16 Mar 2004 00:35:17 +0000 Subject: [PATCH] PR middle-end/14535 * except.c (collect_one_action_chain): Record action for cleanup outer of exception spec. * g++.dg/eh/spec7.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79521 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/except.c | 14 ++++++++++++-- gcc/testsuite/g++.dg/eh/spec7.C | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/eh/spec7.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 458ae138e71..69a0bcc5f48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-03-15 Richard Henderson + + PR middle-end/14535 + * except.c (collect_one_action_chain): Record action for cleanup + outer of exception spec. + 2004-03-15 Ian Lance Taylor * config/rs6000/host-darwin.c (darwin_rs6000_gt_pch_use_address): diff --git a/gcc/except.c b/gcc/except.c index 4e38df26db0..c739650eb9f 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -3365,8 +3365,18 @@ collect_one_action_chain (htab_t ar_hash, struct eh_region *region) /* An exception specification adds its filter to the beginning of the chain. */ next = collect_one_action_chain (ar_hash, region->outer); - return add_action_record (ar_hash, region->u.allowed.filter, - next < 0 ? 0 : next); + + /* If there is no next action, terminate the chain. */ + if (next == -1) + next = 0; + /* If all outer actions are cleanups or must_not_throw, + we'll have no action record for it, since we had wanted + to encode these states in the call-site record directly. + Add a cleanup action to the chain to catch these. */ + else if (next <= 0) + next = add_action_record (ar_hash, 0, 0); + + return add_action_record (ar_hash, region->u.allowed.filter, next); case ERT_MUST_NOT_THROW: /* A must-not-throw region with no inner handlers or cleanups diff --git a/gcc/testsuite/g++.dg/eh/spec7.C b/gcc/testsuite/g++.dg/eh/spec7.C new file mode 100644 index 00000000000..08586a2af75 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/spec7.C @@ -0,0 +1,35 @@ +// PR 14535 +// { dg-do run } +// { dg-options "-O -finline" } +// +// Original test case failure required that Raiser constructor be inlined. + +extern "C" void abort(); +bool destructor_called = false; + +struct B { + virtual void Run(){}; +}; + +struct D : public B { + virtual void Run() + { + struct O { + ~O() { destructor_called = true; }; + } o; + + struct Raiser { + Raiser() throw( int ) {throw 1;}; + } raiser; + }; +}; + +int main() { + try { + D d; + static_cast(d).Run(); + } catch (...) {} + + if (!destructor_called) + abort (); +} -- 2.11.4.GIT