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: libcpp-no-exceptions
10 // test uncaught_exception
11 
12 #include <exception>
13 #include <cassert>
14 
15 struct A
16 {
17     ~A()
18     {
19         assert(std::uncaught_exception());
20     }
21 };
22 
23 struct B
24 {
25     B()
26     {
27         // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
28         assert(!std::uncaught_exception());
29     }
30 };
31 
32 int main(int, char**)
33 {
34     try
35     {
36         A a;
37         assert(!std::uncaught_exception());
38         throw B();
39     }
40     catch (...)
41     {
42         assert(!std::uncaught_exception());
43     }
44     assert(!std::uncaught_exception());
45 
46   return 0;
47 }
48