summaryrefslogtreecommitdiff
path: root/gcc/cp/exception.cc
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1998-01-08 00:29:08 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1998-01-08 00:29:08 +0000
commitdfd19fdfa08d7d954ee01796ed1d9ed1400d6283 (patch)
tree42ae0005def9da50e4d8303d7729478f43847f8c /gcc/cp/exception.cc
parent1096f4afd6691a947daefad4c24e5da4eea701ae (diff)
downloadgcc-dfd19fdfa08d7d954ee01796ed1d9ed1400d6283.tar.gz
* exception.cc (__eh_alloc, __eh_free): New fns.
(__cp_push_exception, __cp_pop_exception): Use them. (__uncatch_exception): Call terminate here if no exception. * except.c (build_terminate_handler): New fn. (expand_start_catch_block): Use it. (expand_exception_blocks): Likewise. (alloc_eh_object): New fn. (expand_throw): Use it. Protect exception init with terminate. * typeck.c (build_modify_expr): Remove code that ignores trivial methods. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@17309 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/exception.cc')
-rw-r--r--gcc/cp/exception.cc46
1 files changed, 35 insertions, 11 deletions
diff --git a/gcc/cp/exception.cc b/gcc/cp/exception.cc
index 399d2c60dbc..0276ed7dad8 100644
--- a/gcc/cp/exception.cc
+++ b/gcc/cp/exception.cc
@@ -29,6 +29,7 @@
#include "typeinfo"
#include "exception"
+#include <stddef.h>
/* Define terminate, unexpected, set_terminate, set_unexpected as
well as the default terminate func and default unexpected func. */
@@ -108,13 +109,37 @@ __cp_exception_info (void)
return *__get_eh_info ();
}
+/* Allocate a buffer for a cp_eh_info and an exception object of size SIZE,
+ and return a pointer to the beginning of the object's space. */
+
+extern "C" void * malloc (size_t);
+extern "C" void *
+__eh_alloc (size_t size)
+{
+ void *p = malloc (size);
+ if (p == 0)
+ terminate ();
+ return p;
+}
+
+/* Free the memory for an cp_eh_info and associated exception, given
+ a pointer to the cp_eh_info. */
+
+extern "C" void free (void *);
+extern "C" void
+__eh_free (void *p)
+{
+ free (p);
+}
+
/* Compiler hook to push a new exception onto the stack.
Used by expand_throw(). */
extern "C" void
__cp_push_exception (void *value, void *type, void (*cleanup)(void *, int))
{
- cp_eh_info *p = new cp_eh_info;
+ cp_eh_info *p = (cp_eh_info *) __eh_alloc (sizeof (cp_eh_info));
+
p->value = value;
p->type = type;
p->cleanup = cleanup;
@@ -155,23 +180,22 @@ __cp_pop_exception (cp_eh_info *p)
*q = p->next;
if (p->cleanup)
- /* 3 is a magic value for destructors; see build_delete(). */
- p->cleanup (p->value, 3);
- else if (__is_pointer (p->type))
- /* do nothing; pointers are passed directly in p->value. */;
- else
- delete p->value;
+ /* 2 is a magic value for destructors; see build_delete(). */
+ p->cleanup (p->value, 2);
- delete p;
+ if (! __is_pointer (p->type))
+ __eh_free (p->value);
+
+ __eh_free (p);
}
extern "C" void
__uncatch_exception (void)
{
cp_eh_info *p = __cp_exception_info ();
- if (p)
- p->caught = false;
- /* otherwise __throw will call terminate(); don't crash here. */
+ if (p == 0)
+ terminate ();
+ p->caught = false;
}
/* As per [except.unexpected]: