[X86] avx512-pmovxrm.ll - replace X32 checks with X86. NFC.
[llvm-project.git] / libcxxabi / test / catch_function_03.pass.cpp
blobe353d0e71c06433f08a509b20e337bd0c5f1f1be
1 //===----------------------------------------------------------------------===//
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 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}}
16 #include <cassert>
18 template<bool Noexcept> void f() noexcept(Noexcept) {}
19 template<bool Noexcept> using FnType = void() noexcept(Noexcept);
21 template<bool ThrowNoexcept, bool CatchNoexcept>
22 void check()
24 try
26 auto *p = f<ThrowNoexcept>;
27 throw p;
28 assert(false);
30 catch (FnType<CatchNoexcept> *p)
32 assert(ThrowNoexcept || !CatchNoexcept);
33 assert(p == &f<ThrowNoexcept>);
35 catch (...)
37 assert(!ThrowNoexcept && CatchNoexcept);
41 void check_deep() {
42 auto *p = f<true>;
43 try
45 throw &p;
47 catch (FnType<false> **q)
49 assert(false);
51 catch (FnType<true> **q)
54 catch (...)
56 assert(false);
60 int main(int, char**)
62 check<false, false>();
63 check<false, true>();
64 check<true, false>();
65 check<true, true>();
66 check_deep();
68 return 0;