1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: no-exceptions |
10 | // test uncaught_exception |
11 | |
12 | #include <exception> |
13 | #include <cassert> |
14 | |
15 | #include "test_macros.h" |
16 | |
17 | struct A |
18 | { |
19 | ~A() |
20 | { |
21 | assert(std::uncaught_exception()); |
22 | } |
23 | }; |
24 | |
25 | struct B |
26 | { |
27 | B() |
28 | { |
29 | // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 |
30 | assert(!std::uncaught_exception()); |
31 | } |
32 | }; |
33 | |
34 | int main(int, char**) |
35 | { |
36 | try |
37 | { |
38 | A a; |
39 | assert(!std::uncaught_exception()); |
40 | throw B(); |
41 | } |
42 | catch (...) |
43 | { |
44 | assert(!std::uncaught_exception()); |
45 | } |
46 | assert(!std::uncaught_exception()); |
47 | |
48 | return 0; |
49 | } |
50 |