1*b725ae77Skettenis /* This testcase is part of GDB, the GNU debugger.
2*b725ae77Skettenis
3*b725ae77Skettenis Copyright 1997, 1998, 2004 Free Software Foundation, Inc.
4*b725ae77Skettenis
5*b725ae77Skettenis This program is free software; you can redistribute it and/or modify
6*b725ae77Skettenis it under the terms of the GNU General Public License as published by
7*b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or
8*b725ae77Skettenis (at your option) any later version.
9*b725ae77Skettenis
10*b725ae77Skettenis This program is distributed in the hope that it will be useful,
11*b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of
12*b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*b725ae77Skettenis GNU General Public License for more details.
14*b725ae77Skettenis
15*b725ae77Skettenis You should have received a copy of the GNU General Public License
16*b725ae77Skettenis along with this program; if not, write to the Free Software
17*b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*b725ae77Skettenis */
19*b725ae77Skettenis
20*b725ae77Skettenis
21*b725ae77Skettenis
22*b725ae77Skettenis // Test file for exception handling support.
23*b725ae77Skettenis
24*b725ae77Skettenis #include <iostream>
25*b725ae77Skettenis using namespace std;
26*b725ae77Skettenis
foo(int i)27*b725ae77Skettenis int foo (int i)
28*b725ae77Skettenis {
29*b725ae77Skettenis if (i < 32)
30*b725ae77Skettenis throw (int) 13;
31*b725ae77Skettenis else
32*b725ae77Skettenis return i * 2;
33*b725ae77Skettenis }
34*b725ae77Skettenis
35*b725ae77Skettenis extern "C" int bar (int k, unsigned long eharg, int flag);
36*b725ae77Skettenis
bar(int k,unsigned long eharg,int flag)37*b725ae77Skettenis int bar (int k, unsigned long eharg, int flag)
38*b725ae77Skettenis {
39*b725ae77Skettenis cout << "k is " << k << " eharg is " << eharg << " flag is " << flag << endl;
40*b725ae77Skettenis return 1;
41*b725ae77Skettenis }
42*b725ae77Skettenis
main()43*b725ae77Skettenis int main()
44*b725ae77Skettenis {
45*b725ae77Skettenis int j;
46*b725ae77Skettenis
47*b725ae77Skettenis try {
48*b725ae77Skettenis j = foo (20);
49*b725ae77Skettenis }
50*b725ae77Skettenis catch (int x) {
51*b725ae77Skettenis cout << "Got an except " << x << endl;
52*b725ae77Skettenis }
53*b725ae77Skettenis
54*b725ae77Skettenis try {
55*b725ae77Skettenis try {
56*b725ae77Skettenis j = foo (20);
57*b725ae77Skettenis }
58*b725ae77Skettenis catch (int x) {
59*b725ae77Skettenis cout << "Got an except " << x << endl;
60*b725ae77Skettenis throw;
61*b725ae77Skettenis }
62*b725ae77Skettenis }
63*b725ae77Skettenis catch (int y) {
64*b725ae77Skettenis cout << "Got an except (rethrown) " << y << endl;
65*b725ae77Skettenis }
66*b725ae77Skettenis
67*b725ae77Skettenis // Not caught
68*b725ae77Skettenis foo (20);
69*b725ae77Skettenis }
70