Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.cp / gdb2495.cc
blob4667e3cb0cfe4f4910b89366c4f69b8dd22fe6ed
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2009-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #include <iostream>
19 #include <signal.h>
21 using namespace std;
23 class SimpleException
26 public:
28 void raise_signal (int dummy)
30 if (dummy > 0)
31 raise(SIGABRT);
34 int no_throw_function ()
36 return 1;
39 void throw_function ()
41 throw 1;
44 int throw_function_with_handler ()
46 try
48 throw 1;
50 catch (...)
52 cout << "Handled" << endl;
55 return 2;
58 void call_throw_function_no_handler ()
60 throw_function ();
63 void call_throw_function_handler ()
65 throw_function_with_handler ();
68 SimpleException exceptions;
70 int
71 main()
73 /* Have to call these functions so GCC does not optimize them
74 away. */
75 exceptions.raise_signal (-1);
76 exceptions.no_throw_function ();
77 exceptions.throw_function_with_handler ();
78 exceptions.call_throw_function_handler ();
79 try
81 exceptions.throw_function ();
82 exceptions.call_throw_function_no_handler ();
84 catch (...)
87 return 0;