Add comment for SelectionDAGBuilder::SL field.
[llvm-project.git] / libcxxabi / test / catch_member_function_pointer_02.pass.cpp
blobc38a9306c41c5cc20da13a6e2f17a0fc98d4f575
1 //===--------------- catch_member_function_pointer_02.cpp -----------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // Can a noexcept member function pointer be caught by a non-noexcept catch
10 // clause?
11 // UNSUPPORTED: no-exceptions, libcxxabi-no-noexcept-function-type
13 // GCC 7 and 8 support noexcept function types but this test still fails.
14 // This is likely a bug in their implementation. Investigation needed.
15 // XFAIL: gcc-7, gcc-8, gcc-9, gcc-10
17 #include <cassert>
19 struct X {
20 template<bool Noexcept> void f() noexcept(Noexcept) {}
22 template<bool Noexcept> using FnType = void (X::*)() noexcept(Noexcept);
24 template<bool ThrowNoexcept, bool CatchNoexcept>
25 void check()
27 try
29 auto p = &X::f<ThrowNoexcept>;
30 throw p;
31 assert(false);
33 catch (FnType<CatchNoexcept> p)
35 assert(ThrowNoexcept || !CatchNoexcept);
36 assert(p == &X::f<ThrowNoexcept>);
38 catch (...)
40 assert(!ThrowNoexcept && CatchNoexcept);
44 void check_deep() {
45 FnType<true> p = &X::f<true>;
46 try
48 throw &p;
50 catch (FnType<false> *q)
52 assert(false);
54 catch (FnType<true> *q)
57 catch (...)
59 assert(false);
63 int main()
65 check<false, false>();
66 check<false, true>();
67 check<true, false>();
68 check<true, true>();
69 check_deep();