Commit | Line | Data |
---|---|---|
e36d075a MC |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
28e7fd62 | 3 | Copyright 1997-2013 Free Software Foundation, Inc. |
e36d075a MC |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 7 | the Free Software Foundation; either version 3 of the License, or |
e36d075a MC |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
a9762ec7 | 14 | |
e36d075a | 15 | You should have received a copy of the GNU General Public License |
a9762ec7 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
6e19e2bf MC |
17 | */ |
18 | ||
e36d075a | 19 | |
e36d075a | 20 | |
7be570e7 JM |
21 | // Test file for exception handling support. |
22 | ||
041ab88c | 23 | using namespace std; |
7be570e7 JM |
24 | |
25 | int foo (int i) | |
26 | { | |
27 | if (i < 32) | |
28 | throw (int) 13; | |
29 | else | |
30 | return i * 2; | |
31 | } | |
32 | ||
33 | extern "C" int bar (int k, unsigned long eharg, int flag); | |
34 | ||
35 | int bar (int k, unsigned long eharg, int flag) | |
36 | { | |
7be570e7 JM |
37 | return 1; |
38 | } | |
39 | ||
af69a5ce YQ |
40 | int catcher (int x) |
41 | { | |
42 | return x; | |
43 | } | |
44 | ||
7be570e7 JM |
45 | int main() |
46 | { | |
47 | int j; | |
48 | ||
49 | try { | |
50 | j = foo (20); | |
51 | } | |
52 | catch (int x) { | |
af69a5ce | 53 | catcher (x); |
7be570e7 JM |
54 | } |
55 | ||
56 | try { | |
57 | try { | |
58 | j = foo (20); | |
59 | } | |
60 | catch (int x) { | |
af69a5ce | 61 | catcher (x); |
7be570e7 JM |
62 | throw; |
63 | } | |
64 | } | |
65 | catch (int y) { | |
af69a5ce | 66 | catcher (y); |
7be570e7 JM |
67 | } |
68 | ||
69 | // Not caught | |
70 | foo (20); | |
7be570e7 | 71 | } |