1*4e43c760Sespie // HP-UX libunwind.so doesn't provide _Unwind_ForcedUnwind.
2*4e43c760Sespie // { dg-do run { xfail "ia64-hp-hpux11.*" } }
3c87b03e5Sespie 
4c87b03e5Sespie // Test that leaving the catch block without rethrowing
5c87b03e5Sespie // does call the exception object destructor.
6c87b03e5Sespie 
7c87b03e5Sespie #include <unwind.h>
8c87b03e5Sespie #include <stdlib.h>
9c87b03e5Sespie 
10c87b03e5Sespie 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)11c87b03e5Sespie force_unwind_stop (int version, _Unwind_Action actions,
12c87b03e5Sespie                    _Unwind_Exception_Class exc_class,
13c87b03e5Sespie                    struct _Unwind_Exception *exc_obj,
14c87b03e5Sespie                    struct _Unwind_Context *context,
15c87b03e5Sespie                    void *stop_parameter)
16c87b03e5Sespie {
17c87b03e5Sespie   if (actions & _UA_END_OF_STACK)
18c87b03e5Sespie     abort ();
19c87b03e5Sespie   return _URC_NO_REASON;
20c87b03e5Sespie }
21c87b03e5Sespie 
22c87b03e5Sespie static void
force_unwind_cleanup(_Unwind_Reason_Code,struct _Unwind_Exception *)23c87b03e5Sespie force_unwind_cleanup (_Unwind_Reason_Code, struct _Unwind_Exception *)
24c87b03e5Sespie {
25c87b03e5Sespie   exit (0);
26c87b03e5Sespie }
27c87b03e5Sespie 
28c87b03e5Sespie static void
force_unwind()29c87b03e5Sespie force_unwind ()
30c87b03e5Sespie {
31c87b03e5Sespie   _Unwind_Exception *exc = new _Unwind_Exception;
32c87b03e5Sespie   exc->exception_class = 0;
33c87b03e5Sespie   exc->exception_cleanup = force_unwind_cleanup;
34c87b03e5Sespie 
35c87b03e5Sespie #ifndef __USING_SJLJ_EXCEPTIONS__
36c87b03e5Sespie   _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
37c87b03e5Sespie #else
38c87b03e5Sespie   _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
39c87b03e5Sespie #endif
40c87b03e5Sespie 
41c87b03e5Sespie   abort ();
42c87b03e5Sespie }
43c87b03e5Sespie 
main()44c87b03e5Sespie int main()
45c87b03e5Sespie {
46c87b03e5Sespie   try {
47c87b03e5Sespie     force_unwind ();
48c87b03e5Sespie   } catch (...) {
49c87b03e5Sespie   }
50c87b03e5Sespie   abort ();
51c87b03e5Sespie }
52