Clang] Fix expansion of response files in -Wp after integrated-cc1 change
[llvm-project.git] / libcxxabi / test / catch_ptr_02.pass.cpp
blob9c24e11df54e4d6be1b5d89d4a3a6a94d704e1cb
1 //===------------------------- catch_ptr_02.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
11 #include <cassert>
13 // Clang emits warnings about exceptions of type 'Child' being caught by
14 // an earlier handler of type 'Base'. Congrats clang, you've just
15 // diagnosed the behavior under test.
16 #if defined(__clang__)
17 #pragma clang diagnostic ignored "-Wexceptions"
18 #endif
20 #if __cplusplus < 201103L
21 #define DISABLE_NULLPTR_TESTS
22 #endif
24 struct A {};
25 A a;
26 const A ca = A();
28 void test1 ()
30 try
32 throw &a;
33 assert(false);
35 catch ( const A* )
38 catch ( A *)
40 assert (false);
44 void test2 ()
46 try
48 throw &a;
49 assert(false);
51 catch ( A* )
54 catch ( const A *)
56 assert (false);
60 void test3 ()
62 try
64 throw &ca;
65 assert(false);
67 catch ( const A* )
70 catch ( A *)
72 assert (false);
76 void test4 ()
78 try
80 throw &ca;
81 assert(false);
83 catch ( A *)
85 assert (false);
87 catch ( const A* )
92 struct base1 {int x;};
93 struct base2 {int x;};
94 struct derived : base1, base2 {};
96 void test5 ()
98 try
100 throw (derived*)0;
101 assert(false);
103 catch (base2 *p) {
104 assert (p == 0);
106 catch (...)
108 assert (false);
112 void test6 ()
114 #if !defined(DISABLE_NULLPTR_TESTS)
117 throw nullptr;
118 assert(false);
120 catch (base2 *p) {
121 assert (p == nullptr);
123 catch (...)
125 assert (false);
127 #endif
130 void test7 ()
134 throw (derived*)12;
135 assert(false);
137 catch (base2 *p) {
138 assert ((unsigned long)p == 12+sizeof(base1));
140 catch (...)
142 assert (false);
147 struct vBase {};
148 struct vDerived : virtual public vBase {};
150 void test8 ()
152 vDerived derived;
155 throw &derived;
156 assert(false);
158 catch (vBase *p) {
159 assert(p != 0);
161 catch (...)
163 assert (false);
167 void test9 ()
169 #if !defined(DISABLE_NULLPTR_TESTS)
172 throw nullptr;
173 assert(false);
175 catch (vBase *p) {
176 assert(p == 0);
178 catch (...)
180 assert (false);
182 #endif
185 void test10 ()
189 throw (vDerived*)0;
190 assert(false);
192 catch (vBase *p) {
193 assert(p == 0);
195 catch (...)
197 assert (false);
201 int main()
203 test1();
204 test2();
205 test3();
206 test4();
207 test5();
208 test6();
209 test7();
210 test8();
211 test9();
212 test10();