1*4e43c760Sespie // HP-UX libunwind.so doesn't provide _Unwind_ForcedUnwind.
2*4e43c760Sespie // { dg-do run { xfail "ia64-hp-hpux11.*" } }
3c87b03e5Sespie
4c87b03e5Sespie // Test that forced unwinding calls std::unexpected going
5c87b03e5Sespie // throw a nothrow function.
6c87b03e5Sespie
7c87b03e5Sespie #include <unwind.h>
8c87b03e5Sespie #include <stdlib.h>
9c87b03e5Sespie #include <exception>
10c87b03e5Sespie
11c87b03e5Sespie 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)12c87b03e5Sespie force_unwind_stop (int version, _Unwind_Action actions,
13c87b03e5Sespie _Unwind_Exception_Class exc_class,
14c87b03e5Sespie struct _Unwind_Exception *exc_obj,
15c87b03e5Sespie struct _Unwind_Context *context,
16c87b03e5Sespie void *stop_parameter)
17c87b03e5Sespie {
18c87b03e5Sespie if (actions & _UA_END_OF_STACK)
19c87b03e5Sespie abort ();
20c87b03e5Sespie return _URC_NO_REASON;
21c87b03e5Sespie }
22c87b03e5Sespie
23c87b03e5Sespie static void __attribute__((noreturn))
force_unwind()24c87b03e5Sespie force_unwind ()
25c87b03e5Sespie {
26c87b03e5Sespie _Unwind_Exception *exc = new _Unwind_Exception;
27c87b03e5Sespie exc->exception_class = 0;
28c87b03e5Sespie exc->exception_cleanup = 0;
29c87b03e5Sespie
30c87b03e5Sespie #ifndef __USING_SJLJ_EXCEPTIONS__
31c87b03e5Sespie _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
32c87b03e5Sespie #else
33c87b03e5Sespie _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
34c87b03e5Sespie #endif
35c87b03e5Sespie
36c87b03e5Sespie abort ();
37c87b03e5Sespie }
38c87b03e5Sespie
39c87b03e5Sespie static void
handle_unexpected()40c87b03e5Sespie handle_unexpected ()
41c87b03e5Sespie {
42c87b03e5Sespie exit (0);
43c87b03e5Sespie }
44c87b03e5Sespie
45c87b03e5Sespie static void
doit()46c87b03e5Sespie doit () throw()
47c87b03e5Sespie {
48c87b03e5Sespie force_unwind ();
49c87b03e5Sespie }
50c87b03e5Sespie
main()51c87b03e5Sespie int main()
52c87b03e5Sespie {
53c87b03e5Sespie std::set_unexpected (handle_unexpected);
54c87b03e5Sespie doit ();
55c87b03e5Sespie abort ();
56c87b03e5Sespie }
57