xref: /aosp_15_r20/external/libcxxabi/test/catch_function_02.pass.cpp (revision c05d8e5dc3e10f6ce4317e8bc22cc4a25f55fa94)
1*c05d8e5dSAndroid Build Coastguard Worker //===---------------------- catch_function_02.cpp -------------------------===//
2*c05d8e5dSAndroid Build Coastguard Worker //
3*c05d8e5dSAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*c05d8e5dSAndroid Build Coastguard Worker //
5*c05d8e5dSAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open
6*c05d8e5dSAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details.
7*c05d8e5dSAndroid Build Coastguard Worker //
8*c05d8e5dSAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*c05d8e5dSAndroid Build Coastguard Worker 
10*c05d8e5dSAndroid Build Coastguard Worker // Can you have a catch clause of array type that catches anything?
11*c05d8e5dSAndroid Build Coastguard Worker // UNSUPPORTED: libcxxabi-no-exceptions
12*c05d8e5dSAndroid Build Coastguard Worker 
13*c05d8e5dSAndroid Build Coastguard Worker #include <cassert>
14*c05d8e5dSAndroid Build Coastguard Worker 
f()15*c05d8e5dSAndroid Build Coastguard Worker void f() {}
16*c05d8e5dSAndroid Build Coastguard Worker 
main()17*c05d8e5dSAndroid Build Coastguard Worker int main()
18*c05d8e5dSAndroid Build Coastguard Worker {
19*c05d8e5dSAndroid Build Coastguard Worker     typedef void Function();
20*c05d8e5dSAndroid Build Coastguard Worker     try
21*c05d8e5dSAndroid Build Coastguard Worker     {
22*c05d8e5dSAndroid Build Coastguard Worker         throw f;     // converts to void (*)()
23*c05d8e5dSAndroid Build Coastguard Worker         assert(false);
24*c05d8e5dSAndroid Build Coastguard Worker     }
25*c05d8e5dSAndroid Build Coastguard Worker     catch (Function b)  // equivalent to void (*)()
26*c05d8e5dSAndroid Build Coastguard Worker     {
27*c05d8e5dSAndroid Build Coastguard Worker     }
28*c05d8e5dSAndroid Build Coastguard Worker     catch (...)
29*c05d8e5dSAndroid Build Coastguard Worker     {
30*c05d8e5dSAndroid Build Coastguard Worker         assert(false);
31*c05d8e5dSAndroid Build Coastguard Worker     }
32*c05d8e5dSAndroid Build Coastguard Worker }
33