Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / gdb2495.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2009-2013 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
19 #include <iostream>
20 #include <signal.h>
21
22 using namespace std;
23
24 class SimpleException
25 {
26
27 public:
28
29 void raise_signal (int dummy)
30 {
31 if (dummy > 0)
32 raise(SIGABRT);
33 }
34
35 int no_throw_function ()
36 {
37 return 1;
38 }
39
40 void throw_function ()
41 {
42 throw 1;
43 }
44
45 int throw_function_with_handler ()
46 {
47 try
48 {
49 throw 1;
50 }
51 catch (...)
52 {
53 cout << "Handled" << endl;
54 }
55
56 return 2;
57 }
58
59 void call_throw_function_no_handler ()
60 {
61 throw_function ();
62 }
63
64 void call_throw_function_handler ()
65 {
66 throw_function_with_handler ();
67 }
68 };
69 SimpleException exceptions;
70
71 int
72 main()
73 {
74 /* Have to call these functions so GCC does not optimize them
75 away. */
76 exceptions.raise_signal (-1);
77 exceptions.no_throw_function ();
78 exceptions.throw_function_with_handler ();
79 exceptions.call_throw_function_handler ();
80 try
81 {
82 exceptions.throw_function ();
83 exceptions.call_throw_function_no_handler ();
84 }
85 catch (...)
86 {
87 }
88 return 0;
89 }
This page took 0.032597 seconds and 5 git commands to generate.