1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // XFAIL: libcpp-no-exceptions
13 // class nested_exception;
15 // template<class T> void throw_with_nested [[noreturn]] (T&& t);
25 explicit A(int data) : data_(data) {}
27 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
31 : public std::nested_exception
35 explicit B(int data) : data_(data) {}
37 friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
40 #if __cplusplus > 201103L
41 struct Final final {};
50 std::throw_with_nested(a);
62 std::throw_with_nested(a);
65 catch (const std::nested_exception& e)
67 assert(e.nested_ptr() == nullptr);
74 std::throw_with_nested(b);
86 std::throw_with_nested(b);
89 catch (const std::nested_exception& e)
91 assert(e.nested_ptr() == nullptr);
92 const B& b = dynamic_cast<const B&>(e);
100 std::throw_with_nested(i);
108 #if __cplusplus > 201103L
112 std::throw_with_nested(Final());
115 catch (const Final &f)