import gdb-1999-08-16 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / exception.cc
CommitLineData
c906108c
SS
1// Test file for exception handling support.
2
3#include <iostream.h>
4
5int foo (int i)
6{
7 if (i < 32)
8 throw (int) 13;
9 else
10 return i * 2;
11}
12
13extern "C" int bar (int k, unsigned long eharg, int flag);
14
15int bar (int k, unsigned long eharg, int flag)
16{
17 cout << "k is " << k << " eharg is " << eharg << " flag is " << flag << endl;
18 return 1;
19}
20
21int main()
22{
23 int j;
24
25 try {
26 j = foo (20);
27 }
28 catch (int x) {
29 cout << "Got an except " << x << endl;
30 }
31
32 try {
33 try {
34 j = foo (20);
35 }
36 catch (int x) {
37 cout << "Got an except " << x << endl;
38 throw;
39 }
40 }
41 catch (int y) {
42 cout << "Got an except (rethrown) " << y << endl;
43 }
44
45 // Not caught
46 foo (20);
47
48}
This page took 0.035047 seconds and 4 git commands to generate.