2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / eh / forced4.C
blobbe03a7544b6282bc236e9cfa5761c8751413ef73
1 // { dg-do run }
3 // Test that forced unwinding does not call std::unexpected going 
4 // throw a function with a non-empty exception spec.
6 #include <unwind.h>
7 #include <stdlib.h>
9 static _Unwind_Reason_Code
10 force_unwind_stop (int version, _Unwind_Action actions,
11                    _Unwind_Exception_Class exc_class,
12                    struct _Unwind_Exception *exc_obj,
13                    struct _Unwind_Context *context,
14                    void *stop_parameter)
16   if (actions & _UA_END_OF_STACK)
17     abort ();
18   return _URC_NO_REASON;
21 static void __attribute__((noreturn))
22 force_unwind ()
24   _Unwind_Exception *exc = new _Unwind_Exception;
25   exc->exception_class = 0;
26   exc->exception_cleanup = 0;
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
34   abort ();
37 static void
38 doit () throw(int)
40   force_unwind ();
43 int main()
44
45   try {
46     doit ();
47   } catch (...) {
48   }