1*c05d8e5dSAndroid Build Coastguard Worker //===------------------------- unwind_02.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: libcxxabi-no-exceptions 11*c05d8e5dSAndroid Build Coastguard Worker // REQUIRES: c++98 || c++03 || c++11 || c++14 12*c05d8e5dSAndroid Build Coastguard Worker 13*c05d8e5dSAndroid Build Coastguard Worker #include <assert.h> 14*c05d8e5dSAndroid Build Coastguard Worker 15*c05d8e5dSAndroid Build Coastguard Worker #if defined(__GNUC__) 16*c05d8e5dSAndroid Build Coastguard Worker #pragma GCC diagnostic ignored "-Wunreachable-code" 17*c05d8e5dSAndroid Build Coastguard Worker #endif 18*c05d8e5dSAndroid Build Coastguard Worker 19*c05d8e5dSAndroid Build Coastguard Worker struct A 20*c05d8e5dSAndroid Build Coastguard Worker { 21*c05d8e5dSAndroid Build Coastguard Worker static int count; 22*c05d8e5dSAndroid Build Coastguard Worker int id_; AA23*c05d8e5dSAndroid Build Coastguard Worker A() : id_(++count) {} ~AA24*c05d8e5dSAndroid Build Coastguard Worker ~A() {assert(id_ == count--);} 25*c05d8e5dSAndroid Build Coastguard Worker 26*c05d8e5dSAndroid Build Coastguard Worker private: 27*c05d8e5dSAndroid Build Coastguard Worker A(const A&); 28*c05d8e5dSAndroid Build Coastguard Worker A& operator=(const A&); 29*c05d8e5dSAndroid Build Coastguard Worker }; 30*c05d8e5dSAndroid Build Coastguard Worker 31*c05d8e5dSAndroid Build Coastguard Worker int A::count = 0; 32*c05d8e5dSAndroid Build Coastguard Worker 33*c05d8e5dSAndroid Build Coastguard Worker struct B 34*c05d8e5dSAndroid Build Coastguard Worker { 35*c05d8e5dSAndroid Build Coastguard Worker static int count; 36*c05d8e5dSAndroid Build Coastguard Worker int id_; BB37*c05d8e5dSAndroid Build Coastguard Worker B() : id_(++count) {} ~BB38*c05d8e5dSAndroid Build Coastguard Worker ~B() {assert(id_ == count--);} 39*c05d8e5dSAndroid Build Coastguard Worker 40*c05d8e5dSAndroid Build Coastguard Worker private: 41*c05d8e5dSAndroid Build Coastguard Worker B(const B&); 42*c05d8e5dSAndroid Build Coastguard Worker B& operator=(const B&); 43*c05d8e5dSAndroid Build Coastguard Worker }; 44*c05d8e5dSAndroid Build Coastguard Worker 45*c05d8e5dSAndroid Build Coastguard Worker int B::count = 0; 46*c05d8e5dSAndroid Build Coastguard Worker 47*c05d8e5dSAndroid Build Coastguard Worker struct C 48*c05d8e5dSAndroid Build Coastguard Worker { 49*c05d8e5dSAndroid Build Coastguard Worker static int count; 50*c05d8e5dSAndroid Build Coastguard Worker int id_; CC51*c05d8e5dSAndroid Build Coastguard Worker C() : id_(++count) {} ~CC52*c05d8e5dSAndroid Build Coastguard Worker ~C() {assert(id_ == count--);} 53*c05d8e5dSAndroid Build Coastguard Worker 54*c05d8e5dSAndroid Build Coastguard Worker private: 55*c05d8e5dSAndroid Build Coastguard Worker C(const C&); 56*c05d8e5dSAndroid Build Coastguard Worker C& operator=(const C&); 57*c05d8e5dSAndroid Build Coastguard Worker }; 58*c05d8e5dSAndroid Build Coastguard Worker 59*c05d8e5dSAndroid Build Coastguard Worker int C::count = 0; 60*c05d8e5dSAndroid Build Coastguard Worker f2()61*c05d8e5dSAndroid Build Coastguard Workervoid f2() 62*c05d8e5dSAndroid Build Coastguard Worker { 63*c05d8e5dSAndroid Build Coastguard Worker C c; 64*c05d8e5dSAndroid Build Coastguard Worker A a; 65*c05d8e5dSAndroid Build Coastguard Worker throw 55; 66*c05d8e5dSAndroid Build Coastguard Worker B b; 67*c05d8e5dSAndroid Build Coastguard Worker } 68*c05d8e5dSAndroid Build Coastguard Worker f1()69*c05d8e5dSAndroid Build Coastguard Workervoid f1() throw (long, char, int, double) 70*c05d8e5dSAndroid Build Coastguard Worker { 71*c05d8e5dSAndroid Build Coastguard Worker A a; 72*c05d8e5dSAndroid Build Coastguard Worker B b; 73*c05d8e5dSAndroid Build Coastguard Worker f2(); 74*c05d8e5dSAndroid Build Coastguard Worker C c; 75*c05d8e5dSAndroid Build Coastguard Worker } 76*c05d8e5dSAndroid Build Coastguard Worker main()77*c05d8e5dSAndroid Build Coastguard Workerint main() 78*c05d8e5dSAndroid Build Coastguard Worker { 79*c05d8e5dSAndroid Build Coastguard Worker try 80*c05d8e5dSAndroid Build Coastguard Worker { 81*c05d8e5dSAndroid Build Coastguard Worker f1(); 82*c05d8e5dSAndroid Build Coastguard Worker assert(false); 83*c05d8e5dSAndroid Build Coastguard Worker } 84*c05d8e5dSAndroid Build Coastguard Worker catch (int* i) 85*c05d8e5dSAndroid Build Coastguard Worker { 86*c05d8e5dSAndroid Build Coastguard Worker assert(false); 87*c05d8e5dSAndroid Build Coastguard Worker } 88*c05d8e5dSAndroid Build Coastguard Worker catch (long i) 89*c05d8e5dSAndroid Build Coastguard Worker { 90*c05d8e5dSAndroid Build Coastguard Worker assert(false); 91*c05d8e5dSAndroid Build Coastguard Worker } 92*c05d8e5dSAndroid Build Coastguard Worker catch (int i) 93*c05d8e5dSAndroid Build Coastguard Worker { 94*c05d8e5dSAndroid Build Coastguard Worker assert(i == 55); 95*c05d8e5dSAndroid Build Coastguard Worker } 96*c05d8e5dSAndroid Build Coastguard Worker catch (...) 97*c05d8e5dSAndroid Build Coastguard Worker { 98*c05d8e5dSAndroid Build Coastguard Worker assert(false); 99*c05d8e5dSAndroid Build Coastguard Worker } 100*c05d8e5dSAndroid Build Coastguard Worker assert(A::count == 0); 101*c05d8e5dSAndroid Build Coastguard Worker assert(B::count == 0); 102*c05d8e5dSAndroid Build Coastguard Worker assert(C::count == 0); 103*c05d8e5dSAndroid Build Coastguard Worker } 104