[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / libcxxabi / test / catch_member_data_pointer_01.pass.cpp
blobe2ffab5aeeef0b77124d176351dace59a276b40d
1 //===----------------------------------------------------------------------===//
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: no-exceptions
11 // 1b00fc5d8133 made it in the dylib in macOS 10.11
12 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10}}
14 #include <cassert>
16 struct A
18 A() : i(0), j(0) {} // explicitly initialize 'i' to prevent warnings
19 const int i;
20 int j;
23 typedef const int A::*md1;
24 typedef int A::*md2;
26 struct B : public A
28 B() : k(0), l(0) {} // explicitly initialize 'k' to prevent warnings.
29 const int k;
30 int l;
33 typedef const int B::*der1;
34 typedef int B::*der2;
36 void test1()
38 try
40 throw &A::i;
41 assert(false);
43 catch (md2)
45 assert(false);
47 catch (md1)
52 // Check that cv qualified conversions are allowed.
53 void test2()
55 try
57 throw &A::j;
59 catch (md2)
62 catch (...)
64 assert(false);
67 try
69 throw &A::j;
70 assert(false);
72 catch (md1)
75 catch (...)
77 assert(false);
81 // Check that Base -> Derived conversions are NOT allowed.
82 void test3()
84 try
86 throw &A::i;
87 assert(false);
89 catch (md2)
91 assert(false);
93 catch (der2)
95 assert(false);
97 catch (der1)
99 assert(false);
101 catch (md1)
106 // Check that Base -> Derived conversions NOT are allowed with different cv
107 // qualifiers.
108 void test4()
112 throw &A::j;
113 assert(false);
115 catch (der2)
117 assert(false);
119 catch (der1)
121 assert(false);
123 catch (md2)
126 catch (...)
128 assert(false);
132 // Check that no Derived -> Base conversions are allowed.
133 void test5()
137 throw &B::k;
138 assert(false);
140 catch (md1)
142 assert(false);
144 catch (md2)
146 assert(false);
148 catch (der1)
154 throw &B::l;
155 assert(false);
157 catch (md1)
159 assert(false);
161 catch (md2)
163 assert(false);
165 catch (der2)
170 int main(int, char**)
172 test1();
173 test2();
174 test3();
175 test4();
176 test5();
178 return 0;