1 //===--------------- catch_member_function_pointer_02.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 // Can a noexcept member function pointer be caught by a non-noexcept catch
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
20 template<bool Noexcept
> void f() noexcept(Noexcept
) {}
22 template<bool Noexcept
> using FnType
= void (X::*)() noexcept(Noexcept
);
24 template<bool ThrowNoexcept
, bool CatchNoexcept
>
29 auto p
= &X::f
<ThrowNoexcept
>;
33 catch (FnType
<CatchNoexcept
> p
)
35 assert(ThrowNoexcept
|| !CatchNoexcept
);
36 assert(p
== &X::f
<ThrowNoexcept
>);
40 assert(!ThrowNoexcept
&& CatchNoexcept
);
45 FnType
<true> p
= &X::f
<true>;
50 catch (FnType
<false> *q
)
54 catch (FnType
<true> *q
)
65 check
<false, false>();