Revert "Roll NDK to r11c and extract it into its own repository."
[android_tools.git] / ndk / sources / cxx-stl / gabi++ / tests / unwind_02.cpp
blob94d53adc4165882c35f40dabe02dda1e0796d426
1 //===------------------------- unwind_02.cpp ------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include <assert.h>
12 struct A
14 static int count;
15 int id_;
16 A() : id_(++count) {}
17 ~A() {assert(id_ == count--);}
19 private:
20 A(const A&);
21 A& operator=(const A&);
24 int A::count = 0;
26 struct B
28 static int count;
29 int id_;
30 B() : id_(++count) {}
31 ~B() {assert(id_ == count--);}
33 private:
34 B(const B&);
35 B& operator=(const B&);
38 int B::count = 0;
40 struct C
42 static int count;
43 int id_;
44 C() : id_(++count) {}
45 ~C() {assert(id_ == count--);}
47 private:
48 C(const C&);
49 C& operator=(const C&);
52 int C::count = 0;
54 void f2()
56 C c;
57 A a;
58 throw 55;
59 B b;
62 void f1() throw (long, char, int, double)
64 A a;
65 B b;
66 f2();
67 C c;
70 int main()
72 try
74 f1();
75 assert(false);
77 catch (int* i)
79 assert(false);
81 catch (long i)
83 assert(false);
85 catch (int i)
87 assert(i == 55);
89 catch (...)
91 assert(false);
93 assert(A::count == 0);
94 assert(B::count == 0);
95 assert(C::count == 0);