Commit | Line | Data |
---|---|---|
e36d075a MC |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3666a048 | 3 | Copyright 1997-2021 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 |
47d48711 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
e36d075a | 17 | |
7be570e7 JM |
18 | // Test file for exception handling support. |
19 | ||
7be570e7 JM |
20 | int foo (int i) |
21 | { | |
22 | if (i < 32) | |
23 | throw (int) 13; | |
24 | else | |
25 | return i * 2; | |
26 | } | |
27 | ||
28 | extern "C" int bar (int k, unsigned long eharg, int flag); | |
29 | ||
30 | int bar (int k, unsigned long eharg, int flag) | |
31 | { | |
7be570e7 JM |
32 | return 1; |
33 | } | |
34 | ||
af69a5ce YQ |
35 | int catcher (int x) |
36 | { | |
37 | return x; | |
38 | } | |
39 | ||
7be570e7 JM |
40 | int main() |
41 | { | |
42 | int j; | |
43 | ||
44 | try { | |
45 | j = foo (20); | |
46 | } | |
47 | catch (int x) { | |
af69a5ce | 48 | catcher (x); |
7be570e7 JM |
49 | } |
50 | ||
51 | try { | |
52 | try { | |
53 | j = foo (20); | |
54 | } | |
55 | catch (int x) { | |
af69a5ce | 56 | catcher (x); |
7be570e7 JM |
57 | throw; |
58 | } | |
59 | } | |
60 | catch (int y) { | |
af69a5ce | 61 | catcher (y); |
7be570e7 JM |
62 | } |
63 | ||
64 | // Not caught | |
65 | foo (20); | |
7be570e7 | 66 | } |