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 // XFAIL: libcpp-no-exceptions 11 // <exception> 12 13 // class nested_exception; 14 15 // nested_exception(const nested_exception&) throw() = default; 16 17 #include <exception> 18 #include <cassert> 19 20 class A 21 { 22 int data_; 23 public: 24 explicit A(int data) : data_(data) {} 25 26 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} 27 }; 28 29 int main() 30 { 31 { 32 std::nested_exception e0; 33 std::nested_exception e = e0; 34 assert(e.nested_ptr() == nullptr); 35 } 36 { 37 try 38 { 39 throw A(2); 40 assert(false); 41 } 42 catch (const A&) 43 { 44 std::nested_exception e0; 45 std::nested_exception e = e0; 46 assert(e.nested_ptr() != nullptr); 47 try 48 { 49 rethrow_exception(e.nested_ptr()); 50 assert(false); 51 } 52 catch (const A& a) 53 { 54 assert(a == A(2)); 55 } 56 } 57 } 58 } 59