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: macosx10.7
14 // XFAIL: macosx10.8
15 // XFAIL: macosx10.9
16 // XFAIL: macosx10.10
17 // XFAIL: macosx10.11
18 // XFAIL: with_system_cxx_lib=macosx10.12
19 // XFAIL: with_system_cxx_lib=macosx10.13
20 
21 // test uncaught_exceptions
22 
23 #include <exception>
24 #include <cassert>
25 
26 struct Uncaught {
UncaughtUncaught27     Uncaught(int depth) : d_(depth) {}
~UncaughtUncaught28     ~Uncaught() { assert(std::uncaught_exceptions() == d_); }
29     int d_;
30     };
31 
32 struct Outer {
OuterOuter33     Outer(int depth) : d_(depth) {}
~OuterOuter34     ~Outer() {
35     try {
36         assert(std::uncaught_exceptions() == d_);
37         Uncaught u(d_+1);
38         throw 2;
39     }
40     catch (int) {}
41     }
42     int d_;
43 };
44 
main()45 int main () {
46     assert(std::uncaught_exceptions() == 0);
47     {
48     Outer o(0);
49     }
50 
51     assert(std::uncaught_exceptions() == 0);
52     {
53     try {
54         Outer o(1);
55         throw 1;
56         }
57     catch (int) {
58         assert(std::uncaught_exceptions() == 0);
59         }
60     }
61     assert(std::uncaught_exceptions() == 0);
62 }
63