xref: /aosp_15_r20/external/cronet/third_party/libc++abi/src/test/uncaught_exceptions.pass.cpp (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: no-exceptions
10 
11 // __cxa_uncaught_exceptions is not re-exported from libc++ until macOS 10.15.
12 // XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
13 
14 #include <cxxabi.h>
15 #include <cassert>
16 
17 // namespace __cxxabiv1 {
18 //      extern unsigned int __cxa_uncaught_exceptions() throw();
19 // }
20 
21 struct A {
AA22     A(unsigned cnt) : data_(cnt) {}
~AA23     ~A() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
24     unsigned data_;
25 };
26 
main()27 int main () {
28     try { A a(1); throw 3; assert(false); }
29     catch (int) {}
30 }
31