brintos

brintos / llvm-project-archived public Read only

0
0
Text · 23.5 KiB · 9bb448f Raw
431 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fms-extensions -verify -triple i686-pc-win32 %s2// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fms-extensions -verify -triple x86_64-pc-win32 %s3 4// FIXME: Extend this portion of the test to cover the 64-bit case.5#if !_M_X646 7// Pointers to free functions8void            free_func_default();9void __cdecl    free_func_cdecl();10void __stdcall  free_func_stdcall();11void __fastcall free_func_fastcall();12 13typedef void (           *fptr_default)();14typedef void (__cdecl    *fptr_cdecl)();15typedef void (__stdcall  *fptr_stdcall)();16typedef void (__fastcall *fptr_fastcall)();17 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}}22void 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}}27void 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}}31void 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}}35void 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}}38void cb_fptr_const_default(const fptr_default ptr);39 40void 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'}}49 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'}}58 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'}}63 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);68 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'}}73 74}75 76// Pointers to variadic functions77// variadic function can't declared stdcall or fastcall78void         free_func_variadic_default(int, ...);79void __cdecl free_func_variadic_cdecl(int, ...);80 81typedef void (        *fptr_variadic_default)(int, ...);82typedef void (__cdecl *fptr_variadic_cdecl)(int, ...);83 84void cb_fptr_variadic_default(fptr_variadic_default ptr);85void cb_fptr_variadic_cdecl(fptr_variadic_cdecl ptr);86 87void 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);92 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);97}98 99// References to functions100typedef void (           &fref_default)();101typedef void (__cdecl    &fref_cdecl)();102typedef void (__stdcall  &fref_stdcall)();103typedef void (__fastcall &fref_fastcall)();104 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}}107void 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}}110void 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}}114void 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}}118void cb_fref_fastcall(fref_fastcall ptr);119 120void 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'}}125 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'}}130 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'}}135 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);140}141 142// References to variadic functions143// variadic function can't declared stdcall or fastcall144typedef void (        &fref_variadic_default)(int, ...);145typedef void (__cdecl &fref_variadic_cdecl)(int, ...);146 147void cb_fref_variadic_default(fptr_variadic_default ptr);148void cb_fref_variadic_cdecl(fptr_variadic_cdecl ptr);149 150void call_free_variadic_func_ref() {151  cb_fref_variadic_default(free_func_variadic_default);152  cb_fref_variadic_default(free_func_variadic_cdecl);153 154  cb_fref_variadic_cdecl(free_func_variadic_default);155  cb_fref_variadic_cdecl(free_func_variadic_cdecl);156}157 158// Pointers to members159namespace NonVariadic {160 161struct A {162  void            member_default();163  void __cdecl    member_cdecl();164  void __thiscall member_thiscall();165};166 167struct B : public A {168};169 170struct C {171  void            member_default();172  void __cdecl    member_cdecl();173  void __thiscall member_thiscall();174};175 176typedef void (           A::*memb_a_default)();177typedef void (__cdecl    A::*memb_a_cdecl)();178typedef void (__thiscall A::*memb_a_thiscall)();179typedef void (           B::*memb_b_default)();180typedef void (__cdecl    B::*memb_b_cdecl)();181typedef void (__thiscall B::*memb_b_thiscall)();182typedef void (           C::*memb_c_default)();183typedef void (__cdecl    C::*memb_c_cdecl)();184typedef void (__thiscall C::*memb_c_thiscall)();185 186// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_a_default' (aka 'void (A::*)() __attribute__((thiscall))') for 1st argument}}187void cb_memb_a_default(memb_a_default ptr);188// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_a_cdecl' (aka 'void (A::*)() __attribute__((cdecl))') for 1st argument}}189// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_a_cdecl' (aka 'void (A::*)() __attribute__((cdecl))') for 1st argument}}190void cb_memb_a_cdecl(memb_a_cdecl ptr);191// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_a_thiscall' (aka 'void (A::*)() __attribute__((thiscall))') for 1st argument}}192void cb_memb_a_thiscall(memb_a_thiscall ptr);193// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_b_default' (aka 'void (B::*)() __attribute__((thiscall))') for 1st argument}}194void cb_memb_b_default(memb_b_default ptr);195// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_b_cdecl' (aka 'void (B::*)() __attribute__((cdecl))') for 1st argument}}196// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_b_cdecl' (aka 'void (B::*)() __attribute__((cdecl))') for 1st argument}}197void cb_memb_b_cdecl(memb_b_cdecl ptr);198// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_b_thiscall' (aka 'void (B::*)() __attribute__((thiscall))') for 1st argument}}199void cb_memb_b_thiscall(memb_b_thiscall ptr);200// expected-note@+3 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_default' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}201// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_c_default' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}202// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_default' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}203void cb_memb_c_default(memb_c_default ptr);204// expected-note@+3 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_cdecl' (aka 'void (C::*)() __attribute__((cdecl))') for 1st argument}}205// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_c_cdecl' (aka 'void (C::*)() __attribute__((cdecl))') for 1st argument}}206// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_cdecl' (aka 'void (C::*)() __attribute__((cdecl))') for 1st argument}}207void cb_memb_c_cdecl(memb_c_cdecl ptr);208// expected-note@+3 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_thiscall' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}209// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((cdecl))' to 'memb_c_thiscall' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}210// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)() __attribute__((thiscall))' to 'memb_c_thiscall' (aka 'void (C::*)() __attribute__((thiscall))') for 1st argument}}211void cb_memb_c_thiscall(memb_c_thiscall ptr);212 213void call_member() {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);217 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'}}221 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);225}226 227void 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'}}234 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'}}241 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'}}248}249} // end namespace NonVariadic250 251#endif  // !_M_X64252 253namespace Variadic {254struct A {255  void            member_default(int, ...);256  void __cdecl    member_cdecl(int, ...);257  void __thiscall member_thiscall(int, ...);258#if !_M_X64259  // expected-error@-2 {{variadic function cannot use thiscall calling convention}}260#endif261};262 263struct B : public A {264};265 266struct C {267  void            member_default(int, ...);268  void __cdecl    member_cdecl(int, ...);269};270 271typedef void (           A::*memb_a_default)(int, ...);272typedef void (__cdecl    A::*memb_a_cdecl)(int, ...);273typedef void (           B::*memb_b_default)(int, ...);274typedef void (__cdecl    B::*memb_b_cdecl)(int, ...);275typedef void (           C::*memb_c_default)(int, ...);276typedef void (__cdecl    C::*memb_c_cdecl)(int, ...);277 278void cb_memb_a_default(memb_a_default ptr);279void cb_memb_a_cdecl(memb_a_cdecl ptr);280void cb_memb_b_default(memb_b_default ptr);281void cb_memb_b_cdecl(memb_b_cdecl ptr);282// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)(int, ...)' to 'memb_c_default' (aka 'void (C::*)(int, ...)') for 1st argument}}283// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)(int, ...) __attribute__((cdecl))' to 'memb_c_default' (aka 'void (C::*)(int, ...)') for 1st argument}}284void cb_memb_c_default(memb_c_default ptr);285// expected-note@+2 {{candidate function not viable: no known conversion from 'void (A::*)(int, ...)' to 'memb_c_cdecl' (aka 'void (C::*)(int, ...) __attribute__((cdecl))') for 1st argument}}286// expected-note@+1 {{candidate function not viable: no known conversion from 'void (A::*)(int, ...) __attribute__((cdecl))' to 'memb_c_cdecl' (aka 'void (C::*)(int, ...) __attribute__((cdecl))') for 1st argument}}287void cb_memb_c_cdecl(memb_c_cdecl ptr);288 289void call_member() {290  cb_memb_a_default(&A::member_default);291  cb_memb_a_default(&A::member_cdecl);292 293  cb_memb_a_cdecl(&A::member_default);294  cb_memb_a_cdecl(&A::member_cdecl);295}296 297void 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'}}302 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'}}307}308} // end namespace Variadic309 310namespace MultiChunkDecls {311 312// Try to test declarators that have multiple DeclaratorChunks.313struct A {314  void __thiscall member_thiscall(int);315};316 317void (A::*return_mptr(short))(int) {318  return &A::member_thiscall;319}320 321void (A::*(*return_fptr_mptr(char))(short))(int) {322  return return_mptr;323}324 325typedef void (A::*mptr_t)(int);326mptr_t __stdcall return_mptr_std(short) {327  return &A::member_thiscall;328}329 330void (A::*(*return_fptr_std_mptr(char))(short))(int) {331  return return_mptr_std;332#if !_M_X64333  // expected-error@-2 {{cannot initialize return object of type 'void (A::*(*)(short))(int) __attribute__((thiscall))' with an lvalue of type 'mptr_t (short) __attribute__((stdcall))'}}334#endif335}336 337void call_return() {338  A o;339  void (A::*(*fptr)(short))(int) = return_fptr_mptr('a');340  void (A::*mptr)(int) = fptr(1);341  (o.*mptr)(2);342}343 344} // end namespace MultiChunkDecls345 346namespace MemberPointers {347 348struct A {349  void __thiscall method_thiscall();350  void __cdecl    method_cdecl();351  void __stdcall  method_stdcall();352  void __fastcall method_fastcall();353};354 355void (           A::*mp1)() = &A::method_thiscall;356void (__cdecl    A::*mp2)() = &A::method_cdecl;357void (__stdcall  A::*mp3)() = &A::method_stdcall;358void (__fastcall A::*mp4)() = &A::method_fastcall;359 360// Use a typedef to form the member pointer and verify that cdecl is adjusted.361typedef void (           fun_default)();362typedef void (__cdecl    fun_cdecl)();363typedef void (__stdcall  fun_stdcall)();364typedef void (__fastcall fun_fastcall)();365 366fun_default  A::*td1 = &A::method_thiscall;367fun_cdecl    A::*td2 = &A::method_thiscall;368fun_stdcall  A::*td3 = &A::method_stdcall;369fun_fastcall A::*td4 = &A::method_fastcall;370 371// Round trip the function type through a template, and verify that only cdecl372// gets adjusted.373template<typename Fn> struct X { typedef Fn A::*p; };374 375X<void            ()>::p tmpl1 = &A::method_thiscall;376X<void __cdecl    ()>::p tmpl2 = &A::method_thiscall;377X<void __stdcall  ()>::p tmpl3 = &A::method_stdcall;378X<void __fastcall ()>::p tmpl4 = &A::method_fastcall;379 380X<fun_default >::p tmpl5 = &A::method_thiscall;381X<fun_cdecl   >::p tmpl6 = &A::method_thiscall;382X<fun_stdcall >::p tmpl7 = &A::method_stdcall;383X<fun_fastcall>::p tmpl8 = &A::method_fastcall;384 385// Make sure we adjust thiscall to cdecl when extracting the function type from386// a member pointer.387template <typename> struct Y;388 389template <typename Fn, typename C>390struct Y<Fn C::*> {391  typedef Fn *p;392};393 394void __cdecl f_cdecl();395Y<decltype(&A::method_thiscall)>::p tmpl9 = &f_cdecl;396 397 398} // end namespace MemberPointers399 400// Test that lambdas that capture nothing convert to cdecl function pointers.401namespace Lambdas {402void pass_fptr_cdecl   (void (__cdecl    *fp)());403void pass_fptr_stdcall (void (__stdcall  *fp)());404void pass_fptr_fastcall(void (__fastcall *fp)());405 406void conversion_to_fptr() {407  pass_fptr_cdecl   ([]() { } );408 409  pass_fptr_stdcall ([]() { } );410#if !_M_X64411  // expected-error@-2 {{no matching function for call}}412  // expected-note@-9 {{candidate function not viable}}413#endif414 415  pass_fptr_fastcall([]() { } );416#if !_M_X64417  // expected-error@-2 {{no matching function for call}}418  // expected-note@-14 {{candidate function not viable}}419#endif420}421}422 423namespace D50526 {424  template<typename T, T (__stdcall f)()> void g();425  void h() { g<void, h>(); }426#if !_M_X64427  // expected-error@-2 {{no matching function for call to}}428  // expected-note@-4 {{invalid explicitly-specified argument}}429#endif430}431