OSDN Git Service

* gcc.dg/altivec-vec-merge.c: Make test usable on GNU/Linux targets
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cleanup-5.c
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.  */
6
7 #include <unwind.h>
8 #include <stdlib.h>
9
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)
16 {
17   if (actions & _UA_END_OF_STACK)
18     abort ();
19   return _URC_NO_REASON;
20 }
21
22 static void force_unwind ()
23 {
24   struct _Unwind_Exception *exc = malloc (sizeof (*exc));
25   exc->exception_class = 0;
26   exc->exception_cleanup = 0;
27                    
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
33                    
34   abort ();
35 }
36
37 static void handler (void *p __attribute__((unused)))
38 {
39   exit (0);
40 }
41
42 static void doit ()
43 {
44   char dummy __attribute__((cleanup (handler)));
45   force_unwind ();
46 }
47
48 int main()
49
50   doit ();
51   abort ();
52 }