1*c05d8e5dSAndroid Build Coastguard Worker //===----------------------- noexception2.pass.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 11*c05d8e5dSAndroid Build Coastguard Worker // REQUIRES: libcxxabi-no-exceptions 12*c05d8e5dSAndroid Build Coastguard Worker 13*c05d8e5dSAndroid Build Coastguard Worker #include <cxxabi.h> 14*c05d8e5dSAndroid Build Coastguard Worker #include <exception> 15*c05d8e5dSAndroid Build Coastguard Worker #include <cassert> 16*c05d8e5dSAndroid Build Coastguard Worker #include <stdlib.h> 17*c05d8e5dSAndroid Build Coastguard Worker 18*c05d8e5dSAndroid Build Coastguard Worker // namespace __cxxabiv1 { 19*c05d8e5dSAndroid Build Coastguard Worker // void __cxa_decrement_exception_refcount(void *thrown_object) throw(); 20*c05d8e5dSAndroid Build Coastguard Worker // } 21*c05d8e5dSAndroid Build Coastguard Worker 22*c05d8e5dSAndroid Build Coastguard Worker unsigned gCounter = 0; 23*c05d8e5dSAndroid Build Coastguard Worker my_terminate()24*c05d8e5dSAndroid Build Coastguard Workervoid my_terminate() { exit(0); } 25*c05d8e5dSAndroid Build Coastguard Worker main()26*c05d8e5dSAndroid Build Coastguard Workerint main () 27*c05d8e5dSAndroid Build Coastguard Worker { 28*c05d8e5dSAndroid Build Coastguard Worker // should not call std::terminate() 29*c05d8e5dSAndroid Build Coastguard Worker __cxxabiv1::__cxa_decrement_exception_refcount(nullptr); 30*c05d8e5dSAndroid Build Coastguard Worker 31*c05d8e5dSAndroid Build Coastguard Worker std::set_terminate(my_terminate); 32*c05d8e5dSAndroid Build Coastguard Worker 33*c05d8e5dSAndroid Build Coastguard Worker // should call std::terminate() 34*c05d8e5dSAndroid Build Coastguard Worker __cxxabiv1::__cxa_decrement_exception_refcount((void*) &gCounter); 35*c05d8e5dSAndroid Build Coastguard Worker assert(false); 36*c05d8e5dSAndroid Build Coastguard Worker 37*c05d8e5dSAndroid Build Coastguard Worker return 0; 38*c05d8e5dSAndroid Build Coastguard Worker } 39