1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: libcpp-no-exceptions
11 // XFAIL: libcpp-no-exceptions
12 
13 // XFAIL: availability=macosx10.7
14 // XFAIL: availability=macosx10.8
15 // XFAIL: availability=macosx10.9
16 // XFAIL: availability=macosx10.10
17 // XFAIL: availability=macosx10.11
18 
19 // test uncaught_exceptions
20 
21 #include <exception>
22 #include <cassert>
23 
24 struct A
25 {
26     ~A()
27     {
28         assert(std::uncaught_exceptions() > 0);
29     }
30 };
31 
32 struct B
33 {
34     B()
35     {
36         // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
37         assert(std::uncaught_exceptions() == 0);
38     }
39 };
40 
41 int main()
42 {
43     try
44     {
45         A a;
46         assert(std::uncaught_exceptions() == 0);
47         throw B();
48     }
49     catch (...)
50     {
51         assert(std::uncaught_exception() == 0);
52     }
53     assert(std::uncaught_exceptions() == 0);
54 }
55