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 // UNSUPPORTED: libcpp-no-exceptions
13 // class nested_exception;
15 // template<class T> void throw_with_nested [[noreturn]] (T&& t);
21 #include "test_macros.h"
27 explicit A(int data) : data_(data) {}
29 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
33 : public std::nested_exception
37 explicit B(int data) : data_(data) {}
39 friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
43 struct Final final {};
52 std::throw_with_nested(a);
64 std::throw_with_nested(a);
67 catch (const std::nested_exception& e)
69 assert(e.nested_ptr() == nullptr);
76 std::throw_with_nested(b);
88 std::throw_with_nested(b);
91 catch (const std::nested_exception& e)
93 assert(e.nested_ptr() == nullptr);
94 const B& b = dynamic_cast<const B&>(e);
102 std::throw_with_nested(i);
110 #if TEST_STD_VER > 11
114 std::throw_with_nested(Final());
117 catch (const Final &)