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 // exception_ptr has not been implemented on Windows 11 // XFAIL: LIBCXX-WINDOWS-FIXME 12 13 // <exception> 14 15 // class nested_exception; 16 17 // nested_exception& operator=(const nested_exception&) throw() = default; 18 19 #include <exception> 20 #include <cassert> 21 22 #include "test_macros.h" 23 24 class A 25 { 26 int data_; 27 public: 28 explicit A(int data) : data_(data) {} 29 30 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} 31 }; 32 33 int main() 34 { 35 { 36 std::nested_exception e0; 37 std::nested_exception e; 38 e = e0; 39 assert(e.nested_ptr() == nullptr); 40 } 41 #ifndef TEST_HAS_NO_EXCEPTIONS 42 { 43 try 44 { 45 throw A(2); 46 assert(false); 47 } 48 catch (const A&) 49 { 50 std::nested_exception e0; 51 std::nested_exception e; 52 e = e0; 53 assert(e.nested_ptr() != nullptr); 54 try 55 { 56 rethrow_exception(e.nested_ptr()); 57 assert(false); 58 } 59 catch (const A& a) 60 { 61 assert(a == A(2)); 62 } 63 } 64 } 65 #endif 66 } 67