[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / libcxxabi / test / catch_member_function_pointer_01.pass.cpp
blobfcb7eeef4b5516f87dc4f9210b410cbd54e89d8b
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 // GCC incorrectly allows PMF type "void (T::*)()" to be caught as "void (T::*)() const"
10 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69375
11 // XFAIL: gcc
12 // UNSUPPORTED: no-exceptions
13 #include <cassert>
15 struct A
17 void foo() {}
18 void bar() const {}
21 typedef void (A::*mf1)();
22 typedef void (A::*mf2)() const;
24 struct B : public A
28 typedef void (B::*dmf1)();
29 typedef void (B::*dmf2)() const;
31 template <class Tp>
32 bool can_convert(Tp) { return true; }
34 template <class>
35 bool can_convert(...) { return false; }
38 void test1()
40 try
42 throw &A::foo;
43 assert(false);
45 catch (mf2)
47 assert(false);
49 catch (mf1)
54 void test2()
56 try
58 throw &A::bar;
59 assert(false);
61 catch (mf1)
63 assert(false);
65 catch (mf2)
72 void test_derived()
74 try
76 throw (mf1)0;
77 assert(false);
79 catch (dmf2)
81 assert(false);
83 catch (dmf1)
85 assert(false);
87 catch (mf1)
91 try
93 throw (mf2)0;
94 assert(false);
96 catch (dmf1)
98 assert(false);
100 catch (dmf2)
102 assert(false);
104 catch (mf2)
108 assert(!can_convert<mf1>((dmf1)0));
109 assert(!can_convert<mf2>((dmf1)0));
112 throw (dmf1)0;
113 assert(false);
115 catch (mf2)
117 assert(false);
119 catch (mf1)
121 assert(false);
123 catch (...)
127 assert(!can_convert<mf1>((dmf2)0));
128 assert(!can_convert<mf2>((dmf2)0));
131 throw (dmf2)0;
132 assert(false);
134 catch (mf2)
136 assert(false);
138 catch (mf1)
140 assert(false);
142 catch (...)
147 void test_void()
149 assert(!can_convert<void*>(&A::foo));
152 throw &A::foo;
153 assert(false);
155 catch (void*)
157 assert(false);
159 catch(...)
164 int main(int, char**)
166 test1();
167 test2();
168 test_derived();
169 test_void();
171 return 0;