1 //===---------------------- catch_function_03.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 function pointer be caught by a non-noexcept catch clause?
10 // UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type
14 template<bool Noexcept
> void f() noexcept(Noexcept
) {}
15 template<bool Noexcept
> using FnType
= void() noexcept(Noexcept
);
17 template<bool ThrowNoexcept
, bool CatchNoexcept
>
22 auto *p
= f
<ThrowNoexcept
>;
26 catch (FnType
<CatchNoexcept
> *p
)
28 assert(ThrowNoexcept
|| !CatchNoexcept
);
29 assert(p
== &f
<ThrowNoexcept
>);
33 assert(!ThrowNoexcept
&& CatchNoexcept
);
43 catch (FnType
<false> **q
)
47 catch (FnType
<true> **q
)
58 check
<false, false>();