* gcc.dg/ucnid-[23456].c: XFAIL on AIX.
[official-gcc.git] / gcc / testsuite / gcc.dg / cleanup-5.c
blob497ab0be90f8bd802abdb0d8374320f2ffacf473
1 /* HP-UX libunwind.so doesn't provide _UA_END_OF_STACK */
2 /* { dg-do run } */
3 /* { dg-options "-fexceptions" } */
4 /* { dg-skip-if "" { "ia64-*-hpux11.*" } { "*" } { "" } } */
5 /* Verify that cleanups work with exception handling. */
7 #include <unwind.h>
8 #include <stdlib.h>
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,
15 void *stop_parameter)
17 if (actions & _UA_END_OF_STACK)
18 abort ();
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);
30 #else
31 _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
32 #endif
34 abort ();
37 static void handler (void *p __attribute__((unused)))
39 exit (0);
42 static void doit ()
44 char dummy __attribute__((cleanup (handler)));
45 force_unwind ();
48 int main()
50 doit ();
51 abort ();