xref: /aosp_15_r20/external/libcxxabi/test/catch_in_noexcept.pass.cpp (revision c05d8e5dc3e10f6ce4317e8bc22cc4a25f55fa94)
1*c05d8e5dSAndroid Build Coastguard Worker //===---------------------- catch_in_noexcept.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 // UNSUPPORTED: c++98, c++03, libcxxabi-no-exceptions
11*c05d8e5dSAndroid Build Coastguard Worker 
12*c05d8e5dSAndroid Build Coastguard Worker #include <exception>
13*c05d8e5dSAndroid Build Coastguard Worker #include <stdlib.h>
14*c05d8e5dSAndroid Build Coastguard Worker #include <assert.h>
15*c05d8e5dSAndroid Build Coastguard Worker 
16*c05d8e5dSAndroid Build Coastguard Worker struct A {};
17*c05d8e5dSAndroid Build Coastguard Worker 
18*c05d8e5dSAndroid Build Coastguard Worker // Despite being marked as noexcept, this function must have an EHT entry that
19*c05d8e5dSAndroid Build Coastguard Worker // is not 'cantunwind', so that the unwinder can correctly deal with the throw.
f1()20*c05d8e5dSAndroid Build Coastguard Worker void f1() noexcept
21*c05d8e5dSAndroid Build Coastguard Worker {
22*c05d8e5dSAndroid Build Coastguard Worker     try {
23*c05d8e5dSAndroid Build Coastguard Worker         A a;
24*c05d8e5dSAndroid Build Coastguard Worker         throw a;
25*c05d8e5dSAndroid Build Coastguard Worker         assert(false);
26*c05d8e5dSAndroid Build Coastguard Worker     } catch (...) {
27*c05d8e5dSAndroid Build Coastguard Worker         assert(true);
28*c05d8e5dSAndroid Build Coastguard Worker         return;
29*c05d8e5dSAndroid Build Coastguard Worker     }
30*c05d8e5dSAndroid Build Coastguard Worker     assert(false);
31*c05d8e5dSAndroid Build Coastguard Worker }
32*c05d8e5dSAndroid Build Coastguard Worker 
main()33*c05d8e5dSAndroid Build Coastguard Worker int main()
34*c05d8e5dSAndroid Build Coastguard Worker {
35*c05d8e5dSAndroid Build Coastguard Worker     f1();
36*c05d8e5dSAndroid Build Coastguard Worker }
37