1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: libcpp-no-exceptions
11 // This test fails due to a stack overflow
12 // XFAIL: LIBCXX-WINDOWS-FIXME
16 // class nested_exception;
18 // template <class E> void rethrow_if_nested(const E& e);
24 #include "test_macros.h"
30 explicit A(int data
) : data_(data
) {}
31 virtual ~A() TEST_NOEXCEPT
{}
33 friend bool operator==(const A
& x
, const A
& y
) {return x
.data_
== y
.data_
;}
37 : public std::nested_exception
,
41 explicit B(int data
) : A(data
) {}
42 B(const B
& b
) : A(b
) {}
49 C
* operator&() const { assert(false); return nullptr; } // should not be called
52 class D
: private std::nested_exception
{};
55 class E1
: public std::nested_exception
{};
56 class E2
: public std::nested_exception
{};
57 class E
: public E1
, public E2
{};
64 A
a(3); // not a polymorphic type --> no effect
65 std::rethrow_if_nested(a
);
76 D s
; // inaccessible base class --> no effect
77 std::rethrow_if_nested(s
);
88 E s
; // ambiguous base class --> no effect
89 std::rethrow_if_nested(s
);
112 std::rethrow_if_nested(a
);
125 std::rethrow_if_nested(C());