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 // Can a noexcept function pointer be caught by a non-noexcept catch clause?
10 // UNSUPPORTED: c++03, c++11, c++14
11 // UNSUPPORTED: no-exceptions
13 // Support for catching a function pointer including noexcept was shipped in macOS 10.13
14 // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12}}
18 template<bool Noexcept
> void f() noexcept(Noexcept
) {}
19 template<bool Noexcept
> using FnType
= void() noexcept(Noexcept
);
21 template<bool ThrowNoexcept
, bool CatchNoexcept
>
26 auto *p
= f
<ThrowNoexcept
>;
30 catch (FnType
<CatchNoexcept
> *p
)
32 assert(ThrowNoexcept
|| !CatchNoexcept
);
33 assert(p
== &f
<ThrowNoexcept
>);
37 assert(!ThrowNoexcept
&& CatchNoexcept
);
47 catch (FnType
<false> **q
)
51 catch (FnType
<true> **q
)
62 check
<false, false>();