aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@casey.soma.redhat.com>2000-06-03 02:20:09 +0000
committerJason Merrill <jason@gcc.gnu.org>2000-06-02 22:20:09 -0400
commit6a83e470e7d1687bbd83c776891122efe814c52f (patch)
treecaab236cb72cdba2203ea2f51ada560a2e434ed2 /gcc/cp
parentde695d2c6db46e8272f3c1a04adc9b355a3059f7 (diff)
downloadgcc-6a83e470e7d1687bbd83c776891122efe814c52f.zip
gcc-6a83e470e7d1687bbd83c776891122efe814c52f.tar.gz
gcc-6a83e470e7d1687bbd83c776891122efe814c52f.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/exception.cc61
2 files changed, 59 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fc78de7..20e5058 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2000-06-02 Jason Merrill <jason@casey.soma.redhat.com>
+
+ * 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 <kenner@vlsi1.ultra.nyu.edu>
* 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 a38477b..9263bfe 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;
}