This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / testsuite / g++.dg / eh / forced3.C
blob29d65d915519690cd5d64818451fc27c728cfd38
1 // HP-UX libunwind.so doesn't provide _Unwind_ForcedUnwind.
2 // { dg-do run { xfail "ia64-hp-hpux11.*" } }
4 // Test that forced unwinding calls std::unexpected going 
5 // throw a nothrow function.
7 #include <unwind.h>
8 #include <stdlib.h>
9 #include <exception>
11 static _Unwind_Reason_Code
12 force_unwind_stop (int version, _Unwind_Action actions,
13                    _Unwind_Exception_Class exc_class,
14                    struct _Unwind_Exception *exc_obj,
15                    struct _Unwind_Context *context,
16                    void *stop_parameter)
18   if (actions & _UA_END_OF_STACK)
19     abort ();
20   return _URC_NO_REASON;
23 static void __attribute__((noreturn))
24 force_unwind ()
26   _Unwind_Exception *exc = new _Unwind_Exception;
27   exc->exception_class = 0;
28   exc->exception_cleanup = 0;
30 #ifndef __USING_SJLJ_EXCEPTIONS__
31   _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
32 #else
33   _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
34 #endif
36   abort ();
39 static void
40 handle_unexpected ()
42   exit (0);
45 static void
46 doit () throw()
48   force_unwind ();
51 int main()
52
53   std::set_unexpected (handle_unexpected);
54   doit ();
55   abort ();