xref: /aosp_15_r20/external/libcxxabi/test/catch_array_01.pass.cpp (revision c05d8e5dc3e10f6ce4317e8bc22cc4a25f55fa94)
1*c05d8e5dSAndroid Build Coastguard Worker //===---------------------- catch_array_01.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 
12*c05d8e5dSAndroid Build Coastguard Worker // GCC incorrectly allows array types to be caught by reference.
13*c05d8e5dSAndroid Build Coastguard Worker // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
14*c05d8e5dSAndroid Build Coastguard Worker // XFAIL: gcc
15*c05d8e5dSAndroid Build Coastguard Worker // UNSUPPORTED: libcxxabi-no-exceptions
16*c05d8e5dSAndroid Build Coastguard Worker 
17*c05d8e5dSAndroid Build Coastguard Worker #include <cassert>
18*c05d8e5dSAndroid Build Coastguard Worker 
main()19*c05d8e5dSAndroid Build Coastguard Worker int main()
20*c05d8e5dSAndroid Build Coastguard Worker {
21*c05d8e5dSAndroid Build Coastguard Worker     typedef char Array[4];
22*c05d8e5dSAndroid Build Coastguard Worker     Array a = {'H', 'i', '!', 0};
23*c05d8e5dSAndroid Build Coastguard Worker     try
24*c05d8e5dSAndroid Build Coastguard Worker     {
25*c05d8e5dSAndroid Build Coastguard Worker         throw a;  // converts to char*
26*c05d8e5dSAndroid Build Coastguard Worker         assert(false);
27*c05d8e5dSAndroid Build Coastguard Worker     }
28*c05d8e5dSAndroid Build Coastguard Worker     catch (Array& b)  // can't catch char*
29*c05d8e5dSAndroid Build Coastguard Worker     {
30*c05d8e5dSAndroid Build Coastguard Worker         assert(false);
31*c05d8e5dSAndroid Build Coastguard Worker     }
32*c05d8e5dSAndroid Build Coastguard Worker     catch (...)
33*c05d8e5dSAndroid Build Coastguard Worker     {
34*c05d8e5dSAndroid Build Coastguard Worker     }
35*c05d8e5dSAndroid Build Coastguard Worker }
36