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: no-exceptions
11 // FIXME: This test fails in MSVC mode due to a stack overflow
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 A(const A
&) = default;
32 A
& operator=(const A
&) = default;
33 virtual ~A() TEST_NOEXCEPT
{}
35 friend bool operator==(const A
& x
, const A
& y
) {return x
.data_
== y
.data_
;}
39 : public std::nested_exception
,
43 explicit B(int data
) : A(data
) {}
44 B(const B
& b
) : A(b
) {}
51 C
* operator&() const { assert(false); return nullptr; } // should not be called
54 class D
: private std::nested_exception
{};
57 class E1
: public std::nested_exception
{};
58 class E2
: public std::nested_exception
{};
59 class E
: public E1
, public E2
{};
66 A
a(3); // not a polymorphic type --> no effect
67 std::rethrow_if_nested(a
);
78 D s
; // inaccessible base class --> no effect
79 std::rethrow_if_nested(s
);
90 E s
; // ambiguous base class --> no effect
91 std::rethrow_if_nested(s
);
114 std::rethrow_if_nested(a
);
127 std::rethrow_if_nested(C());