]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
30a333ce PC |
2 | |
3 | // 2008-05-25 Sebastian Redl <sebastian.redl@getdesigned.at> | |
4 | ||
99dee823 | 5 | // Copyright (C) 2008-2021 Free Software Foundation, Inc. |
30a333ce PC |
6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
748086b7 | 10 | // Free Software Foundation; either version 3, or (at your option) |
30a333ce PC |
11 | // any later version. |
12 | ||
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | ||
18 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
19 | // with this library; see the file COPYING3. If not see |
20 | // <http://www.gnu.org/licenses/>. | |
30a333ce PC |
21 | |
22 | // current_exception() under various conditions. | |
23 | ||
24 | #include <exception> | |
25 | #include <testsuite_hooks.h> | |
26 | ||
27 | void test01() | |
28 | { | |
30a333ce PC |
29 | using namespace std; |
30 | ||
31 | exception_ptr ep = current_exception(); | |
110a123a | 32 | VERIFY( ep == 0 ); |
30a333ce PC |
33 | } |
34 | ||
35 | void test02() | |
36 | { | |
30a333ce PC |
37 | using namespace std; |
38 | ||
39 | try { | |
40 | throw 0; | |
41 | } catch(...) { | |
42 | exception_ptr ep = current_exception(); | |
110a123a | 43 | VERIFY( ep != 0 ); |
30a333ce PC |
44 | } |
45 | } | |
46 | ||
47 | void test03() | |
48 | { | |
30a333ce PC |
49 | using namespace std; |
50 | ||
51 | try { | |
52 | throw exception(); | |
53 | } catch(std::exception&) { | |
54 | exception_ptr ep = current_exception(); | |
110a123a | 55 | VERIFY( ep != 0 ); |
30a333ce PC |
56 | } |
57 | } | |
58 | ||
59 | void test04() | |
60 | { | |
30a333ce PC |
61 | using namespace std; |
62 | ||
63 | try { | |
64 | throw 0; | |
65 | } catch(...) { | |
66 | exception_ptr ep1 = current_exception(); | |
67 | try { | |
68 | throw 0; | |
69 | } catch(...) { | |
70 | exception_ptr ep2 = current_exception(); | |
71 | VERIFY( ep1 != ep2 ); | |
72 | } | |
73 | exception_ptr ep3 = current_exception(); | |
74 | // Not guaranteed by standard, but by this implementation. | |
75 | VERIFY( ep1 == ep3 ); | |
76 | } | |
77 | } | |
78 | ||
79 | int main() | |
80 | { | |
81 | test01(); | |
82 | test02(); | |
83 | test03(); | |
84 | test04(); | |
85 | return 0; | |
86 | } |