1 //===--------------------- inherited_exception.cpp ------------------------===//
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 // This test case checks specifically the cases under C++ ABI 15.3.1, and 15.3.2
12 // A handler is a match for an exception object of type E if
13 // / * The handler is of type cv T or cv T& and E and T are the same type \
14 // | (ignoring the top-level cv-qualifiers), or |
15 // | * the handler is of type cv T or cv T& and T is an unambiguous base |
17 // * the handler is of type cv1 T* cv2 and E is a pointer type that can
18 // be converted to the type of the handler by either or both of
19 // o a standard pointer conversion (4.10 [conv.ptr]) not involving
20 // conversions to private or protected or ambiguous classes
21 // o a qualification conversion
22 // * the handler is a pointer or pointer to member type and E is
25 //===----------------------------------------------------------------------===//
27 // UNSUPPORTED: libcxxabi-no-exceptions
29 // Clang emits warnings about exceptions of type 'Child' being caught by
30 // an earlier handler of type 'Base'. Congrats clang, you've just
31 // diagnosed the behavior under test.
32 #if defined(__clang__)
33 #pragma clang diagnostic ignored "-Wexceptions"
46 struct Child
: public Base
, public Base2
{
63 throw static_cast<Base2
&>(child
);
71 throw static_cast<Base2
*>(&child
);
81 catch (const Child
& c
)
103 catch (const Child
& b
)
117 catch (const Base2
& c
)
121 catch (const Child
& b
)
135 catch (const Child
& c
)
139 catch (const Base
& b
)
143 catch (const Base2
& b
)
157 catch (const Base
* c
)
161 catch (const Child
* b
)
165 catch (const Base2
* c
)