1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -fms-extensions -verify -triple i686-pc-win32 %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -fms-extensions -verify -triple x86_64-pc-win32 %s
4 // FIXME: Extend this portion of the test to cover the 64-bit case.
7 // Pointers to free functions
8 void free_func_default();
9 void __cdecl
free_func_cdecl();
10 void __stdcall
free_func_stdcall();
11 void __fastcall
free_func_fastcall();
13 typedef void ( *fptr_default
)();
14 typedef void (__cdecl
*fptr_cdecl
)();
15 typedef void (__stdcall
*fptr_stdcall
)();
16 typedef void (__fastcall
*fptr_fastcall
)();
18 // expected-note@+4 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}}
19 // expected-note@+3 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}}
20 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((stdcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}}
21 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((fastcall))' to 'fptr_default' (aka 'void (*)()') for 1st argument}}
22 void cb_fptr_default(fptr_default ptr
);
23 // expected-note@+4 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}}
24 // expected-note@+3 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}}
25 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((stdcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}}
26 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (*)() __attribute__((fastcall))' to 'fptr_cdecl' (aka 'void (*)()') for 1st argument}}
27 void cb_fptr_cdecl(fptr_cdecl ptr
);
28 // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}}
29 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}}
30 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fptr_stdcall' (aka 'void (*)() __attribute__((stdcall))') for 1st argument}}
31 void cb_fptr_stdcall(fptr_stdcall ptr
);
32 // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}}
33 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}}
34 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fptr_fastcall' (aka 'void (*)() __attribute__((fastcall))') for 1st argument}}
35 void cb_fptr_fastcall(fptr_fastcall ptr
);
36 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'const fptr_default' (aka 'void (*const)()') for 1st argument}}
37 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'const fptr_default' (aka 'void (*const)()') for 1st argument}}
38 void cb_fptr_const_default(const fptr_default ptr
);
40 void call_free_func() {
41 cb_fptr_default(free_func_default
);
42 cb_fptr_default(free_func_cdecl
);
43 cb_fptr_default(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_default'}}
44 cb_fptr_default(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_default'}}
45 cb_fptr_default(&free_func_default
);
46 cb_fptr_default(&free_func_cdecl
);
47 cb_fptr_default(&free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_default'}}
48 cb_fptr_default(&free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_default'}}
50 cb_fptr_cdecl(free_func_default
);
51 cb_fptr_cdecl(free_func_cdecl
);
52 cb_fptr_cdecl(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}}
53 cb_fptr_cdecl(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}}
54 cb_fptr_cdecl(&free_func_default
);
55 cb_fptr_cdecl(&free_func_cdecl
);
56 cb_fptr_cdecl(&free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}}
57 cb_fptr_cdecl(&free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_cdecl'}}
59 cb_fptr_stdcall(free_func_default
); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}}
60 cb_fptr_stdcall(free_func_cdecl
); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}}
61 cb_fptr_stdcall(free_func_stdcall
);
62 cb_fptr_stdcall(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_stdcall'}}
64 cb_fptr_fastcall(free_func_default
); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}}
65 cb_fptr_fastcall(free_func_cdecl
); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}}
66 cb_fptr_fastcall(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_fastcall'}}
67 cb_fptr_fastcall(free_func_fastcall
);
69 cb_fptr_const_default(free_func_default
);
70 cb_fptr_const_default(free_func_cdecl
);
71 cb_fptr_const_default(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fptr_const_default'}}
72 cb_fptr_const_default(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fptr_const_default'}}
76 // Pointers to variadic functions
77 // variadic function can't declared stdcall or fastcall
78 void free_func_variadic_default(int, ...);
79 void __cdecl
free_func_variadic_cdecl(int, ...);
81 typedef void ( *fptr_variadic_default
)(int, ...);
82 typedef void (__cdecl
*fptr_variadic_cdecl
)(int, ...);
84 void cb_fptr_variadic_default(fptr_variadic_default ptr
);
85 void cb_fptr_variadic_cdecl(fptr_variadic_cdecl ptr
);
87 void call_free_variadic_func() {
88 cb_fptr_variadic_default(free_func_variadic_default
);
89 cb_fptr_variadic_default(free_func_variadic_cdecl
);
90 cb_fptr_variadic_default(&free_func_variadic_default
);
91 cb_fptr_variadic_default(&free_func_variadic_cdecl
);
93 cb_fptr_variadic_cdecl(free_func_variadic_default
);
94 cb_fptr_variadic_cdecl(free_func_variadic_cdecl
);
95 cb_fptr_variadic_cdecl(&free_func_variadic_default
);
96 cb_fptr_variadic_cdecl(&free_func_variadic_cdecl
);
99 // References to functions
100 typedef void ( &fref_default
)();
101 typedef void (__cdecl
&fref_cdecl
)();
102 typedef void (__stdcall
&fref_stdcall
)();
103 typedef void (__fastcall
&fref_fastcall
)();
105 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_default' (aka 'void (&)()') for 1st argument}}
106 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_default' (aka 'void (&)()') for 1st argument}}
107 void cb_fref_default(fref_default ptr
);
108 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_cdecl' (aka 'void (&)()') for 1st argument}}
109 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_cdecl' (aka 'void (&)()') for 1st argument}}
110 void cb_fref_cdecl(fref_cdecl ptr
);
111 // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}}
112 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}}
113 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((fastcall))' to 'fref_stdcall' (aka 'void (&)() __attribute__((stdcall))') for 1st argument}}
114 void cb_fref_stdcall(fref_stdcall ptr
);
115 // expected-note@+3 {{candidate function not viable: no known conversion from 'void ()' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}}
116 // expected-note@+2 {{candidate function not viable: no known conversion from 'void () __attribute__((cdecl))' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}}
117 // expected-note@+1 {{candidate function not viable: no known conversion from 'void () __attribute__((stdcall))' to 'fref_fastcall' (aka 'void (&)() __attribute__((fastcall))') for 1st argument}}
118 void cb_fref_fastcall(fref_fastcall ptr
);
120 void call_free_func_ref() {
121 cb_fref_default(free_func_default
);
122 cb_fref_default(free_func_cdecl
);
123 cb_fref_default(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fref_default'}}
124 cb_fref_default(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fref_default'}}
126 cb_fref_cdecl(free_func_default
);
127 cb_fref_cdecl(free_func_cdecl
);
128 cb_fref_cdecl(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fref_cdecl'}}
129 cb_fref_cdecl(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fref_cdecl'}}
131 cb_fref_stdcall(free_func_default
); // expected-error {{no matching function for call to 'cb_fref_stdcall'}}
132 cb_fref_stdcall(free_func_cdecl
); // expected-error {{no matching function for call to 'cb_fref_stdcall'}}
133 cb_fref_stdcall(free_func_stdcall
);
134 cb_fref_stdcall(free_func_fastcall
); // expected-error {{no matching function for call to 'cb_fref_stdcall'}}
136 cb_fref_fastcall(free_func_default
); // expected-error {{no matching function for call to 'cb_fref_fastcall'}}
137 cb_fref_fastcall(free_func_cdecl
); // expected-error {{no matching function for call to 'cb_fref_fastcall'}}
138 cb_fref_fastcall(free_func_stdcall
); // expected-error {{no matching function for call to 'cb_fref_fastcall'}}
139 cb_fref_fastcall(free_func_fastcall
);
142 // References to variadic functions
143 // variadic function can't declared stdcall or fastcall
144 typedef void ( &fref_variadic_default
)(int, ...);
145 typedef void (__cdecl
&fref_variadic_cdecl
)(int, ...);
147 void cb_fref_variadic_default(fptr_variadic_default ptr
);
148 void cb_fref_variadic_cdecl(fptr_variadic_cdecl ptr
);
150 void call_free_variadic_func_ref() {
151 cb_fref_variadic_default(free_func_variadic_default
);
152 cb_fref_variadic_default(free_func_variadic_cdecl
);
154 cb_fref_variadic_cdecl(free_func_variadic_default
);
155 cb_fref_variadic_cdecl(free_func_variadic_cdecl
);
158 // Pointers to members
159 namespace NonVariadic
{
162 void member_default();
163 void __cdecl
member_cdecl();
164 void __thiscall
member_thiscall();
167 struct B
: public A
{
171 void member_default();
172 void __cdecl
member_cdecl();
173 void __thiscall
member_thiscall();
176 typedef void ( A::*memb_a_default
)();
177 typedef void (__cdecl
A::*memb_a_cdecl
)();
178 typedef void (__thiscall
A::*memb_a_thiscall
)();
179 typedef void ( B::*memb_b_default
)();
180 typedef void (__cdecl
B::*memb_b_cdecl
)();
181 typedef void (__thiscall
B::*memb_b_thiscall
)();
182 typedef void ( C::*memb_c_default
)();
183 typedef void (__cdecl
C::*memb_c_cdecl
)();
184 typedef void (__thiscall
C::*memb_c_thiscall
)();
186 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_a_default' (aka 'void (NonVariadic::A::*)() __attribute__((thiscall))') for 1st argument}}
187 void cb_memb_a_default(memb_a_default ptr
);
188 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_a_cdecl' (aka 'void (NonVariadic::A::*)() __attribute__((cdecl))') for 1st argument}}
189 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_a_cdecl' (aka 'void (NonVariadic::A::*)() __attribute__((cdecl))') for 1st argument}}
190 void cb_memb_a_cdecl(memb_a_cdecl ptr
);
191 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_a_thiscall' (aka 'void (NonVariadic::A::*)() __attribute__((thiscall))') for 1st argument}}
192 void cb_memb_a_thiscall(memb_a_thiscall ptr
);
193 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_b_default' (aka 'void (NonVariadic::B::*)() __attribute__((thiscall))') for 1st argument}}
194 void cb_memb_b_default(memb_b_default ptr
);
195 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_b_cdecl' (aka 'void (NonVariadic::B::*)() __attribute__((cdecl))') for 1st argument}}
196 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_b_cdecl' (aka 'void (NonVariadic::B::*)() __attribute__((cdecl))') for 1st argument}}
197 void cb_memb_b_cdecl(memb_b_cdecl ptr
);
198 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_b_thiscall' (aka 'void (NonVariadic::B::*)() __attribute__((thiscall))') for 1st argument}}
199 void cb_memb_b_thiscall(memb_b_thiscall ptr
);
200 // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
201 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
202 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_default' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
203 void cb_memb_c_default(memb_c_default ptr
);
204 // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}}
205 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}}
206 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_cdecl' (aka 'void (NonVariadic::C::*)() __attribute__((cdecl))') for 1st argument}}
207 void cb_memb_c_cdecl(memb_c_cdecl ptr
);
208 // expected-note@+3 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
209 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((cdecl))' to 'NonVariadic::memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
210 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (NonVariadic::A::*)() __attribute__((thiscall))' to 'NonVariadic::memb_c_thiscall' (aka 'void (NonVariadic::C::*)() __attribute__((thiscall))') for 1st argument}}
211 void cb_memb_c_thiscall(memb_c_thiscall ptr
);
214 cb_memb_a_default(&A::member_default
);
215 cb_memb_a_default(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_a_default'}}
216 cb_memb_a_default(&A::member_thiscall
);
218 cb_memb_a_cdecl(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_a_cdecl'}}
219 cb_memb_a_cdecl(&A::member_cdecl
);
220 cb_memb_a_cdecl(&A::member_thiscall
); // expected-error {{no matching function for call to 'cb_memb_a_cdecl'}}
222 cb_memb_a_thiscall(&A::member_default
);
223 cb_memb_a_thiscall(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_a_thiscall'}}
224 cb_memb_a_thiscall(&A::member_thiscall
);
227 void call_member_inheritance() {
228 cb_memb_b_default(&A::member_default
);
229 cb_memb_b_default(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_b_default'}}
230 cb_memb_b_default(&A::member_thiscall
);
231 cb_memb_c_default(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_c_default'}}
232 cb_memb_c_default(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_c_default'}}
233 cb_memb_c_default(&A::member_thiscall
); // expected-error {{no matching function for call to 'cb_memb_c_default'}}
235 cb_memb_b_cdecl(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_b_cdecl'}}
236 cb_memb_b_cdecl(&A::member_cdecl
);
237 cb_memb_b_cdecl(&A::member_thiscall
); // expected-error {{no matching function for call to 'cb_memb_b_cdecl'}}
238 cb_memb_c_cdecl(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}}
239 cb_memb_c_cdecl(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}}
240 cb_memb_c_cdecl(&A::member_thiscall
); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}}
242 cb_memb_b_thiscall(&A::member_default
);
243 cb_memb_b_thiscall(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_b_thiscall'}}
244 cb_memb_b_thiscall(&A::member_thiscall
);
245 cb_memb_c_thiscall(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}}
246 cb_memb_c_thiscall(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}}
247 cb_memb_c_thiscall(&A::member_thiscall
); // expected-error {{no matching function for call to 'cb_memb_c_thiscall'}}
249 } // end namespace NonVariadic
255 void member_default(int, ...);
256 void __cdecl
member_cdecl(int, ...);
257 void __thiscall
member_thiscall(int, ...);
259 // expected-error@-2 {{variadic function cannot use thiscall calling convention}}
263 struct B
: public A
{
267 void member_default(int, ...);
268 void __cdecl
member_cdecl(int, ...);
271 typedef void ( A::*memb_a_default
)(int, ...);
272 typedef void (__cdecl
A::*memb_a_cdecl
)(int, ...);
273 typedef void ( B::*memb_b_default
)(int, ...);
274 typedef void (__cdecl
B::*memb_b_cdecl
)(int, ...);
275 typedef void ( C::*memb_c_default
)(int, ...);
276 typedef void (__cdecl
C::*memb_c_cdecl
)(int, ...);
278 void cb_memb_a_default(memb_a_default ptr
);
279 void cb_memb_a_cdecl(memb_a_cdecl ptr
);
280 void cb_memb_b_default(memb_b_default ptr
);
281 void cb_memb_b_cdecl(memb_b_cdecl ptr
);
282 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...)' to 'Variadic::memb_c_default' (aka 'void (Variadic::C::*)(int, ...)') for 1st argument}}
283 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...) __attribute__((cdecl))' to 'Variadic::memb_c_default' (aka 'void (Variadic::C::*)(int, ...)') for 1st argument}}
284 void cb_memb_c_default(memb_c_default ptr
);
285 // expected-note@+2 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...)' to 'Variadic::memb_c_cdecl' (aka 'void (Variadic::C::*)(int, ...) __attribute__((cdecl))') for 1st argument}}
286 // expected-note@+1 {{candidate function not viable: no known conversion from 'void (Variadic::A::*)(int, ...) __attribute__((cdecl))' to 'Variadic::memb_c_cdecl' (aka 'void (Variadic::C::*)(int, ...) __attribute__((cdecl))') for 1st argument}}
287 void cb_memb_c_cdecl(memb_c_cdecl ptr
);
290 cb_memb_a_default(&A::member_default
);
291 cb_memb_a_default(&A::member_cdecl
);
293 cb_memb_a_cdecl(&A::member_default
);
294 cb_memb_a_cdecl(&A::member_cdecl
);
297 void call_member_inheritance() {
298 cb_memb_b_default(&A::member_default
);
299 cb_memb_b_default(&A::member_cdecl
);
300 cb_memb_c_default(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_c_default'}}
301 cb_memb_c_default(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_c_default'}}
303 cb_memb_b_cdecl(&A::member_default
);
304 cb_memb_b_cdecl(&A::member_cdecl
);
305 cb_memb_c_cdecl(&A::member_default
); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}}
306 cb_memb_c_cdecl(&A::member_cdecl
); // expected-error {{no matching function for call to 'cb_memb_c_cdecl'}}
308 } // end namespace Variadic
310 namespace MultiChunkDecls
{
312 // Try to test declarators that have multiple DeclaratorChunks.
314 void __thiscall
member_thiscall(int);
317 void (A::*return_mptr(short))(int) {
318 return &A::member_thiscall
;
321 void (A::*(*return_fptr_mptr(char))(short))(int) {
325 typedef void (A::*mptr_t
)(int);
326 mptr_t __stdcall
return_mptr_std(short) {
327 return &A::member_thiscall
;
330 void (A::*(*return_fptr_std_mptr(char))(short))(int) {
331 return return_mptr_std
;
333 // expected-error@-2 {{cannot initialize return object of type 'void (MultiChunkDecls::A::*(*)(short))(int) __attribute__((thiscall))' with an lvalue of type 'MultiChunkDecls::mptr_t (short) __attribute__((stdcall))'}}
339 void (A::*(*fptr
)(short))(int) = return_fptr_mptr('a');
340 void (A::*mptr
)(int) = fptr(1);
344 } // end namespace MultiChunkDecls
346 namespace MemberPointers
{
349 void __thiscall
method_thiscall();
350 void __cdecl
method_cdecl();
351 void __stdcall
method_stdcall();
352 void __fastcall
method_fastcall();
355 void ( A::*mp1
)() = &A::method_thiscall
;
356 void (__cdecl
A::*mp2
)() = &A::method_cdecl
;
357 void (__stdcall
A::*mp3
)() = &A::method_stdcall
;
358 void (__fastcall
A::*mp4
)() = &A::method_fastcall
;
360 // Use a typedef to form the member pointer and verify that cdecl is adjusted.
361 typedef void ( fun_default
)();
362 typedef void (__cdecl fun_cdecl
)();
363 typedef void (__stdcall fun_stdcall
)();
364 typedef void (__fastcall fun_fastcall
)();
366 fun_default
A::*td1
= &A::method_thiscall
;
367 fun_cdecl
A::*td2
= &A::method_thiscall
;
368 fun_stdcall
A::*td3
= &A::method_stdcall
;
369 fun_fastcall
A::*td4
= &A::method_fastcall
;
371 // Round trip the function type through a template, and verify that only cdecl
373 template<typename Fn
> struct X
{ typedef Fn
A::*p
; };
375 X
<void ()>::p tmpl1
= &A::method_thiscall
;
376 X
<void __cdecl ()>::p tmpl2
= &A::method_thiscall
;
377 X
<void __stdcall ()>::p tmpl3
= &A::method_stdcall
;
378 X
<void __fastcall ()>::p tmpl4
= &A::method_fastcall
;
380 X
<fun_default
>::p tmpl5
= &A::method_thiscall
;
381 X
<fun_cdecl
>::p tmpl6
= &A::method_thiscall
;
382 X
<fun_stdcall
>::p tmpl7
= &A::method_stdcall
;
383 X
<fun_fastcall
>::p tmpl8
= &A::method_fastcall
;
385 // Make sure we adjust thiscall to cdecl when extracting the function type from
387 template <typename
> struct Y
;
389 template <typename Fn
, typename C
>
394 void __cdecl
f_cdecl();
395 Y
<decltype(&A::method_thiscall
)>::p tmpl9
= &f_cdecl
;
398 } // end namespace MemberPointers
400 // Test that lambdas that capture nothing convert to cdecl function pointers.
402 void pass_fptr_cdecl (void (__cdecl
*fp
)());
403 void pass_fptr_stdcall (void (__stdcall
*fp
)());
404 void pass_fptr_fastcall(void (__fastcall
*fp
)());
406 void conversion_to_fptr() {
407 pass_fptr_cdecl ([]() { } );
409 pass_fptr_stdcall ([]() { } );
411 // expected-error@-2 {{no matching function for call}}
412 // expected-note@-9 {{candidate function not viable}}
415 pass_fptr_fastcall([]() { } );
417 // expected-error@-2 {{no matching function for call}}
418 // expected-note@-14 {{candidate function not viable}}
424 template<typename T
, T (__stdcall f
)()> void g();
425 void h() { g
<void, h
>(); }
427 // expected-error@-2 {{no matching function for call to}}
428 // expected-note@-4 {{invalid explicitly-specified argument}}