Clang] Fix expansion of response files in -Wp after integrated-cc1 change
[llvm-project.git] / libcxxabi / test / unwind_04.pass.cpp
blob45669c354b3fe502beda5b86f92bfb5c83cf04da
1 //===------------------------- unwind_04.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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: libcxxabi-no-exceptions
10 // REQUIRES: c++98 || c++03 || c++11 || c++14
12 #include <exception>
13 #include <stdlib.h>
14 #include <assert.h>
16 #if defined(__GNUC__)
17 #pragma GCC diagnostic ignored "-Wunreachable-code"
18 #endif
20 struct A
22 static int count;
23 int id_;
24 A() : id_(++count) {}
25 ~A() {assert(id_ == count--);}
27 private:
28 A(const A&);
29 A& operator=(const A&);
32 int A::count = 0;
34 struct B
36 static int count;
37 int id_;
38 B() : id_(++count) {}
39 ~B() {assert(id_ == count--);}
41 private:
42 B(const B&);
43 B& operator=(const B&);
46 int B::count = 0;
48 struct C
50 static int count;
51 int id_;
52 C() : id_(++count) {}
53 ~C() {assert(id_ == count--);}
55 private:
56 C(const C&);
57 C& operator=(const C&);
60 int C::count = 0;
62 void f2()
64 C c;
65 A a;
66 throw 55;
67 B b;
70 void f1() throw (long, char, double)
72 A a;
73 B b;
74 f2();
75 C c;
78 void u_handler()
80 throw 'a';
83 int main()
85 std::set_unexpected(u_handler);
86 try
88 f1();
89 assert(false);
91 catch (int* i)
93 assert(false);
95 catch (long i)
97 assert(false);
99 catch (int i)
101 assert(false);
103 catch (char c)
105 assert(c == 'a');
107 catch (...)
109 assert(false);
111 assert(A::count == 0);
112 assert(B::count == 0);
113 assert(C::count == 0);