Commit 6874c264 by Jason Merrill Committed by Jason Merrill

[multiple changes]

Fri Oct 31 01:45:31 1997  Jason Merrill  <jason@yorick.cygnus.com>

	* libgcc2.c (L_eh): Define __eh_pc.
	Replace __eh_type with generic pointer __eh_info.

Fri Oct 31 01:47:57 1997  Jason Merrill  <jason@yorick.cygnus.com>

	Support for nested exceptions.
	* tinfo2.cc (__is_pointer): New fn.
	* exception.cc (struct cp_eh_info): Define.
	(__cp_exception_info, __uncatch_exception): New fns.
	(__cp_push_exception, __cp_pop_exception): New fns.
	* except.c: Lose saved_throw_{type,value,cleanup,in_catch}.
 	Lose empty_fndecl.
	(init_exception_processing): Likewise.  __eh_pc is now external.
	(push_eh_info): New fn.
	(get_eh_{info,value,type,caught}): New fns.
	(push_eh_cleanup): Just call __cp_pop_exception.
	(expand_start_catch_block): Use push_eh_info.  Start the eh region
	sooner.
	(expand_end_eh_spec): Use push_eh_info.
	(expand_throw): Call __cp_push_exception to set up the exception info.
	Just pass the destructor or 0 as the cleanup.  Call __uncatch_exception
	when we rethrow.
	(expand_builtin_throw): Don't refer to empty_fndecl.

From-SVN: r16248
parent 59fe8c2c
Fri Oct 31 01:45:31 1997 Jason Merrill <jason@yorick.cygnus.com>
* libgcc2.c (L_eh): Define __eh_pc.
Replace __eh_type with generic pointer __eh_info.
Fri Oct 31 00:34:55 1996 J"orn Rennecke <amylaar@cygnus.co.uk>
* expr.c (expand_increment): When enqueing a postincrement for a MEM,
......
Fri Oct 31 01:47:57 1997 Jason Merrill <jason@yorick.cygnus.com>
Support for nested exceptions.
* tinfo2.cc (__is_pointer): New fn.
* exception.cc (struct cp_eh_info): Define.
(__cp_exception_info, __uncatch_exception): New fns.
(__cp_push_exception, __cp_pop_exception): New fns.
* except.c: Lose saved_throw_{type,value,cleanup,in_catch}.
Lose empty_fndecl.
(init_exception_processing): Likewise. __eh_pc is now external.
(push_eh_info): New fn.
(get_eh_{info,value,type,caught}): New fns.
(push_eh_cleanup): Just call __cp_pop_exception.
(expand_start_catch_block): Use push_eh_info. Start the eh region
sooner.
(expand_end_eh_spec): Use push_eh_info.
(expand_throw): Call __cp_push_exception to set up the exception info.
Just pass the destructor or 0 as the cleanup. Call __uncatch_exception
when we rethrow.
(expand_builtin_throw): Don't refer to empty_fndecl.
Thu Oct 23 02:01:30 1997 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (instantiate_decl): SET_DECL_IMPLICIT_INSTANTIATION on new decl.
......
......@@ -73,6 +73,79 @@ unexpected ()
__unexpected_func ();
}
/* C++-specific state about the current exception.
This must match init_exception_processing(). */
struct cp_eh_info
{
void *value;
void *type;
void (*cleanup)(void *, int);
bool caught;
cp_eh_info *next;
};
/* Language-specific EH info pointer, defined in libgcc2. */
extern cp_eh_info *__eh_info; // actually void*
/* Is P the type_info node for a pointer of some kind? */
extern bool __is_pointer (void *);
/* Compiler hook to return a pointer to the info for the current exception.
Used by get_eh_info (). */
extern "C" cp_eh_info *
__cp_exception_info (void)
{
return __eh_info;
}
/* 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;
p->value = value;
p->type = type;
p->cleanup = cleanup;
p->caught = false;
p->next = __eh_info;
__eh_info = p;
}
/* Compiler hook to pop an exception that has been finalized. Used by
push_eh_cleanup(). */
extern "C" void
__cp_pop_exception (void)
{
cp_eh_info *p = __eh_info;
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;
__eh_info = p->next;
delete 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. */
}
extern "C" void
__throw_bad_cast (void)
{
......@@ -91,12 +164,13 @@ __throw_bad_exception (void)
throw bad_exception ();
}
/* Has the current exception been caught? */
bool
uncaught_exception ()
{
extern void *__eh_type;
extern bool __eh_in_catch;
return __eh_type && ! __eh_in_catch;
cp_eh_info *p = __cp_exception_info ();
return p && ! p->caught;
}
const char * exception::
......
......@@ -258,6 +258,18 @@ __throw_type_match_rtti (void *catch_type_r, void *throw_type_r, void *objptr)
return new_objptr;
}
/* Called from __cp_pop_exception. Is P the type_info node for a pointer
of some kind? */
bool
__is_pointer (void *p)
{
const type_info *t = reinterpret_cast <const type_info *>(p);
const __pointer_type_info *pt =
dynamic_cast <const __pointer_type_info *> (t);
return pt != 0;
}
extern "C" void
__rtti_ptr (void *addr, const char *n, const type_info *ti)
{ new (addr) __pointer_type_info (n, *ti); }
......
......@@ -3109,7 +3109,9 @@ int _exit_dummy_decl = 0; /* prevent compiler & linker warnings */
/* Shared exception handling support routines. */
extern void *__eh_type;
/* Language-specific information about the active exception(s). If there
are no active exceptions, it is set to 0. */
void *__eh_info;
void
__default_terminate ()
......@@ -3224,7 +3226,7 @@ __sjthrow ()
/* We must call terminate if we try and rethrow an exception, when
there is no exception currently active and when there are no
handlers left. */
if (! __eh_type || (*dhc) == top_elt)
if (! __eh_info || (*dhc) == top_elt)
__terminate ();
/* Find the jmpbuf associated with the top element of the dynamic
......@@ -3307,7 +3309,7 @@ __sjpopnthrow ()
/* This value identifies the place from which an exception is being
thrown. */
extern void *__eh_pc;
void *__eh_pc;
#ifdef EH_TABLE_LOOKUP
......@@ -3652,7 +3654,7 @@ __throw ()
/* This is required for C++ semantics. We must call terminate if we
try and rethrow an exception, when there is no exception currently
active. */
if (! __eh_type)
if (! __eh_info)
__terminate ();
/* Start at our stack frame. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment