From 6a83e470e7d1687bbd83c776891122efe814c52f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 3 Jun 2000 02:20:09 +0000 Subject: [PATCH] exception.cc (__cp_pop_exception): If we aren't popping or rethrowing, push down past any uncaught exceptions. * exception.cc (__cp_pop_exception): If we aren't popping or rethrowing, push down past any uncaught exceptions. (__uncatch_exception): Rethrow the currently handled exception. Move it to the top of the exception stack. From-SVN: r34375 --- gcc/cp/ChangeLog | 7 ++++++ gcc/cp/exception.cc | 61 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc78de7f6185..20e505811674 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2000-06-02 Jason Merrill + + * exception.cc (__cp_pop_exception): If we aren't popping or + rethrowing, push down past any uncaught exceptions. + (__uncatch_exception): Rethrow the currently handled exception. + Move it to the top of the exception stack. + Fri Jun 2 19:38:57 2000 Richard Kenner * cp-tree.h: Use struct tree_common instead of a char array. diff --git a/gcc/cp/exception.cc b/gcc/cp/exception.cc index a38477b050d8..9263bfeaa011 100644 --- a/gcc/cp/exception.cc +++ b/gcc/cp/exception.cc @@ -247,17 +247,37 @@ __cp_push_exception (void *value, void *type, cleanup_fn cleanup) extern "C" void __cp_pop_exception (cp_eh_info *p) { - cp_eh_info **q = __get_eh_info (); + cp_eh_info **stack = __get_eh_info (); + cp_eh_info **q = stack; --p->handlers; - /* Don't really pop if there are still active handlers for our exception, - or if our exception is being rethrown (i.e. if the active exception is - our exception and it is uncaught). */ - if (p->handlers != 0 - || (p == *q && !p->caught)) + /* Do nothing if our exception is being rethrown (i.e. if the active + exception is our exception and it is uncaught). */ + if (p == *q && !p->caught) return; + /* Don't really pop if there are still active handlers for our exception; + rather, push it down past any uncaught exceptions. */ + if (p->handlers != 0) + { + if (p == *q && p->next && !p->next->caught) + { + q = &(p->next); + while (1) + { + if (*q == 0 || (*q)->caught) + break; + + q = &((*q)->next); + } + *stack = p->next; + p->next = *q; + *q = p; + } + return; + } + for (; *q; q = &((*q)->next)) if (*q == p) break; @@ -277,12 +297,35 @@ __cp_pop_exception (cp_eh_info *p) __eh_free (p); } +/* We're doing a rethrow. Find the currently handled exception, mark it + uncaught, and move it to the top of the EH stack. */ + extern "C" void __uncatch_exception (void) { - cp_eh_info *p = CP_EH_INFO; - if (p == 0) - terminate (); + cp_eh_info **stack = __get_eh_info (); + cp_eh_info **q = stack; + cp_eh_info *p; + + while (1) + { + p = *q; + + if (p == 0) + terminate (); + if (p->caught) + break; + + q = &(p->next); + } + + if (q != stack) + { + *q = p->next; + p->next = *stack; + *stack = p; + } + p->caught = false; } -- 2.43.5