Clang] Fix expansion of response files in -Wp after integrated-cc1 change
[llvm-project.git] / libcxxabi / test / catch_function_03.pass.cpp
blobdbc72c722c1e8a06fe48eb0ac3a88be8fe867e25
1 //===---------------------- catch_function_03.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 function pointer be caught by a non-noexcept catch clause?
10 // UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type
12 #include <cassert>
14 template<bool Noexcept> void f() noexcept(Noexcept) {}
15 template<bool Noexcept> using FnType = void() noexcept(Noexcept);
17 template<bool ThrowNoexcept, bool CatchNoexcept>
18 void check()
20 try
22 auto *p = f<ThrowNoexcept>;
23 throw p;
24 assert(false);
26 catch (FnType<CatchNoexcept> *p)
28 assert(ThrowNoexcept || !CatchNoexcept);
29 assert(p == &f<ThrowNoexcept>);
31 catch (...)
33 assert(!ThrowNoexcept && CatchNoexcept);
37 void check_deep() {
38 auto *p = f<true>;
39 try
41 throw &p;
43 catch (FnType<false> **q)
45 assert(false);
47 catch (FnType<true> **q)
50 catch (...)
52 assert(false);
56 int main()
58 check<false, false>();
59 check<false, true>();
60 check<true, false>();
61 check<true, true>();
62 check_deep();