Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.dg / eh / forced3.C
blob96319d44ecd2955d65910ee269ea8e105d5ea9ef
1 // HP-UX libunwind.so doesn't provide _UA_END_OF_STACK.
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>
10 #include <string.h>
12 static _Unwind_Reason_Code
13 force_unwind_stop (int version, _Unwind_Action actions,
14                    _Unwind_Exception_Class exc_class,
15                    struct _Unwind_Exception *exc_obj,
16                    struct _Unwind_Context *context,
17                    void *stop_parameter)
19   if (actions & _UA_END_OF_STACK)
20     abort ();
21   return _URC_NO_REASON;
24 static void __attribute__((noreturn))
25 force_unwind ()
27   _Unwind_Exception *exc = new _Unwind_Exception;
28   // exception_class might not be a scalar.
29   memset (&exc->exception_class, 0, sizeof (exc->exception_class));
30   exc->exception_cleanup = 0;
32 #ifndef __USING_SJLJ_EXCEPTIONS__
33   _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
34 #else
35   _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
36 #endif
38   abort ();
41 static void
42 handle_unexpected ()
44   exit (0);
47 static void
48 doit () throw()
50   force_unwind ();
53 int main()
54
55   std::set_unexpected (handle_unexpected);
56   doit ();
57   abort ();