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& operator=(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; 34 e = e0; 35 assert(e.nested_ptr() == nullptr); 36 } 37 { 38 try 39 { 40 throw A(2); 41 assert(false); 42 } 43 catch (const A&) 44 { 45 std::nested_exception e0; 46 std::nested_exception e; 47 e = e0; 48 assert(e.nested_ptr() != nullptr); 49 try 50 { 51 rethrow_exception(e.nested_ptr()); 52 assert(false); 53 } 54 catch (const A& a) 55 { 56 assert(a == A(2)); 57 } 58 } 59 } 60 } 61