Mercurial > hg > CbC > CbC_llvm
comparison libcxxabi/test/unwind_03.pass.cpp @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 0572611fdcc8 |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 //===------------------------- unwind_03.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: libcxxabi-no-exceptions | |
10 // REQUIRES: c++98 || c++03 || c++11 || c++14 | |
11 | |
12 #include <exception> | |
13 #include <stdlib.h> | |
14 #include <assert.h> | |
15 | |
16 #if defined(__GNUC__) | |
17 #pragma GCC diagnostic ignored "-Wunreachable-code" | |
18 #endif | |
19 | |
20 struct A | |
21 { | |
22 static int count; | |
23 int id_; | |
24 A() : id_(++count) {} | |
25 ~A() {assert(id_ == count--);} | |
26 | |
27 private: | |
28 A(const A&); | |
29 A& operator=(const A&); | |
30 }; | |
31 | |
32 int A::count = 0; | |
33 | |
34 struct B | |
35 { | |
36 static int count; | |
37 int id_; | |
38 B() : id_(++count) {} | |
39 ~B() {assert(id_ == count--);} | |
40 | |
41 private: | |
42 B(const B&); | |
43 B& operator=(const B&); | |
44 }; | |
45 | |
46 int B::count = 0; | |
47 | |
48 struct C | |
49 { | |
50 static int count; | |
51 int id_; | |
52 C() : id_(++count) {} | |
53 ~C() {assert(id_ == count--);} | |
54 | |
55 private: | |
56 C(const C&); | |
57 C& operator=(const C&); | |
58 }; | |
59 | |
60 int C::count = 0; | |
61 | |
62 void f2() | |
63 { | |
64 C c; | |
65 A a; | |
66 throw 55; | |
67 B b; | |
68 } | |
69 | |
70 void f1() throw (long, char, double) | |
71 { | |
72 A a; | |
73 B b; | |
74 f2(); | |
75 C c; | |
76 } | |
77 | |
78 void u_handler() | |
79 { | |
80 exit(0); | |
81 } | |
82 | |
83 int main() | |
84 { | |
85 std::set_unexpected(u_handler); | |
86 try | |
87 { | |
88 f1(); | |
89 assert(false); | |
90 } | |
91 catch (int* i) | |
92 { | |
93 assert(false); | |
94 } | |
95 catch (long i) | |
96 { | |
97 assert(false); | |
98 } | |
99 catch (int i) | |
100 { | |
101 assert(i == 55); | |
102 } | |
103 catch (...) | |
104 { | |
105 assert(false); | |
106 } | |
107 assert(false); | |
108 } |