1 //===------------------- uncaught_exceptions.pass.cpp ---------------------===// 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: with_system_cxx_lib=macosx10.14 13 // XFAIL: with_system_cxx_lib=macosx10.13 14 // XFAIL: with_system_cxx_lib=macosx10.12 15 // XFAIL: with_system_cxx_lib=macosx10.11 16 // XFAIL: with_system_cxx_lib=macosx10.10 17 // XFAIL: with_system_cxx_lib=macosx10.9 18 19 #include <cxxabi.h> 20 #include <cassert> 21 22 // namespace __cxxabiv1 { 23 // extern unsigned int __cxa_uncaught_exceptions() throw(); 24 // } 25 26 struct A { 27 A(unsigned cnt) : data_(cnt) {} 28 ~A() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); } 29 unsigned data_; 30 }; 31 32 int main () { 33 try { A a(1); throw 3; assert(false); } 34 catch (int) {} 35 } 36