1 /* { dg-do run { target *-*-linux* powerpc*-*-darwin* } } */
2 /* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
3 /* Verify that cleanups work with exception handling through signal
10 static _Unwind_Reason_Code
11 force_unwind_stop (int version, _Unwind_Action actions,
12 _Unwind_Exception_Class exc_class,
13 struct _Unwind_Exception *exc_obj,
14 struct _Unwind_Context *context,
17 if (actions & _UA_END_OF_STACK)
19 return _URC_NO_REASON;
22 static void force_unwind ()
24 struct _Unwind_Exception *exc = malloc (sizeof (*exc));
25 exc->exception_class = 0;
26 exc->exception_cleanup = 0;
28 #ifndef __USING_SJLJ_EXCEPTIONS__
29 _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
31 _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
40 static void counter (void *p __attribute__((unused)))
45 static void handler (void *p __attribute__((unused)))
52 static int __attribute__((noinline)) fn5 ()
54 char dummy __attribute__((cleanup (counter)));
59 static void fn4 (int sig)
61 char dummy __attribute__((cleanup (counter)));
71 static int __attribute__((noinline)) fn2 ()
78 static int __attribute__((noinline)) fn1 ()
80 signal (SIGSEGV, fn4);
86 static int __attribute__((noinline)) fn0 ()
88 char dummy __attribute__((cleanup (handler)));