[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / libcxxabi / test / catch_function_01.pass.cpp
blob2ac94db04bcc368762d7ec15a641c5274135353c
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 you have a catch clause of array type that catches anything?
11 // GCC incorrectly allows function pointer to be caught by reference.
12 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
13 // XFAIL: gcc
14 // UNSUPPORTED: no-exceptions
16 // 65ace9daa360 made it in the dylib in macOS 10.11
17 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10}}
19 #include <cassert>
21 template <class Tp>
22 bool can_convert(Tp) { return true; }
24 template <class>
25 bool can_convert(...) { return false; }
27 void f() {}
29 int main(int, char**)
31 typedef void Function();
32 assert(!can_convert<Function&>(&f));
33 assert(!can_convert<void*>(&f));
34 try
36 throw f; // converts to void (*)()
37 assert(false);
39 catch (Function& b) // can't catch void (*)()
41 assert(false);
43 catch (void*) // can't catch as void*
45 assert(false);
47 catch(Function*)
50 catch (...)
52 assert(false);
55 return 0;