1/* This testcase is part of GDB, the GNU debugger.
2
3   Copyright 1997-2023 Free Software Foundation, Inc.
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
7   the Free Software Foundation; either version 3 of the License, or
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.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18// Test file for exception handling support.
19
20int foo (int i)
21{
22  if (i < 32)
23    throw (int) 13;
24  else
25    return i * 2;
26}
27
28extern "C" int bar (int k, unsigned long eharg, int flag);
29
30int bar (int k, unsigned long eharg, int flag)
31{
32  return 1;
33}
34
35int catcher (int x)
36{
37  return x;
38}
39
40int main()
41{
42  int j;
43
44  try {
45    j = foo (20);
46  }
47  catch (int x) {
48    catcher (x);
49  }
50
51  try {
52    try {
53      j = foo (20);
54    }
55    catch (int x) {
56      catcher (x);
57      throw;
58    }
59  }
60  catch (int y) {
61    catcher (y);
62  }
63
64  // Not caught
65  foo (20);
66}
67