Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
EXCEPTION_SPECIFICATION.cpp
Go to the documentation of this file.
1// checking exception specification
2
3
25#include "config.h"
26
27#include <signal.h>
28#include <stdlib.h>
29#include <stdio.h>
30
31#ifndef _RWSTD_NO_HONOR_STD
32# ifdef _RWSTD_NO_STD_TERMINATE
33
34namespace std {
35
36void terminate ()
37{
38 abort ();
39}
40
41} // std
42
43# endif // _RWSTD_NO_STD_TERMINATE
44#endif // _RWSTD_NO_HONOR_STD
45
46extern "C" {
47
48void handle_ABRT (int)
49{
50 // exit successfully
51 exit (0);
52}
53
54} // extern "C"
55
56// test functionality;
57struct X {};
58struct Y {};
59
60void foobar () { throw Y (); }
61void foo () throw (X) { foobar (); }
62
63// test syntax
64void bar (int) throw (int) {}
65
66struct A { };
67struct B
68{
69 B () throw (A*) { }
70 ~B () throw () { }
71};
72
73int main ()
74{
75 signal (SIGABRT, handle_ABRT);
76
77 try {
78 // must not return
79 foo ();
80 }
81 catch (X) {
82 return 1;
83 }
84 catch (Y) {
85 return 2;
86 }
87 catch (...) {
88 return 3;
89 }
90
91 return 4;
92}
#define Y
Definition 17.names.cpp:168
void foobar()
void handle_ABRT(int)
void terminate()
#define SIGABRT
Definition json.h:5363