diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-16 11:52:55 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-16 11:52:55 +0000 |
commit | 31933f89f9d41a0e5af922951c334cbdb0a99596 (patch) | |
tree | da08a4ceb1400ad593f6a055dc2999c204a77e07 /gcc/testsuite/gcc.dg/cleanup-8.c | |
parent | 9fbc9c4d2c5f81941cf45da348627967f4852458 (diff) | |
download | gcc-31933f89f9d41a0e5af922951c334cbdb0a99596.tar.gz |
* unwind-dw2.c (MD_FROB_UPDATE_CONTEXT): Define.
(uw_update_context_1): Use it.
* config/rs6000/rs6000.c (insn_after_throw): Remove.
(rs6000_aix_emit_builtin_unwind_init): Save $r2 to its location
in parent frame if _Unwind_* called directly instead of through
.plt.
(rs6000_emit_eh_toc_restore): Remove.
(rs6000_emit_prologue): Update stack pointer before doing any saving
if current_function_calls_eh_return. Generate unwind info for $r2.
(rs6000_emit_epilogue): Restore stack pointer after doing all
restoring if current_function_calls_eh_return. Restore $r2.
* config/rs6000/rs6000-protos.h (rs6000_emit_eh_toc_restore): Remove.
* config/rs6000/rs6000.md (eh_return): Remove call to
rs6000_emit_eh_toc_restore.
* config/rs6000/linux64.h (MD_FROB_UPDATE_CONTEXT): Define.
* config/rs6000/aix.h (MD_FROB_UPDATE_CONTEXT): Define.
* gcc.dg/cleanup-8.c: New test.
* gcc.dg/cleanup-9.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69450 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/cleanup-8.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cleanup-8.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cleanup-8.c b/gcc/testsuite/gcc.dg/cleanup-8.c new file mode 100644 index 00000000000..91e387ce799 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cleanup-8.c @@ -0,0 +1,97 @@ +/* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* } } */ +/* { dg-options "-fasynchronous-unwind-tables -fexceptions -O2" } */ +/* Verify that cleanups work with exception handling through signal + frames. */ + +#include <unwind.h> +#include <stdlib.h> +#include <signal.h> + +static _Unwind_Reason_Code +force_unwind_stop (int version, _Unwind_Action actions, + _Unwind_Exception_Class exc_class, + struct _Unwind_Exception *exc_obj, + struct _Unwind_Context *context, + void *stop_parameter) +{ + if (actions & _UA_END_OF_STACK) + abort (); + return _URC_NO_REASON; +} + +static void force_unwind () +{ + struct _Unwind_Exception *exc = malloc (sizeof (*exc)); + exc->exception_class = 0; + exc->exception_cleanup = 0; + +#ifndef __USING_SJLJ_EXCEPTIONS__ + _Unwind_ForcedUnwind (exc, force_unwind_stop, 0); +#else + _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0); +#endif + + abort (); +} + +int count; +char *null; + +static void counter (void *p __attribute__((unused))) +{ + ++count; +} + +static void handler (void *p __attribute__((unused))) +{ + if (count != 2) + abort (); + exit (0); +} + +static int __attribute__((noinline)) fn5 () +{ + char dummy __attribute__((cleanup (counter))); + force_unwind (); + return 0; +} + +static void fn4 (int sig) +{ + char dummy __attribute__((cleanup (counter))); + fn5 (); + null = NULL; +} + +static void fn3 () +{ + abort (); +} + +static int __attribute__((noinline)) fn2 () +{ + *null = 0; + fn3 (); + return 0; +} + +static int __attribute__((noinline)) fn1 () +{ + signal (SIGSEGV, fn4); + fn2 (); + return 0; +} + +static int __attribute__((noinline)) fn0 () +{ + char dummy __attribute__((cleanup (handler))); + fn1 (); + null = 0; + return 0; +} + +int main() +{ + fn0 (); + abort (); +} |