1 // Build with "cl.exe /Zi /GR- /GS- -EHs-c- every-function.cpp /link /debug /nodefaultlib /incremental:no /entry:main" 2 // Getting functions with the correct calling conventions requires building in x86. 3 4 // clang-format off 5 void *__purecall = 0; 6 operator delete(void *,unsigned int)7void __cdecl operator delete(void *,unsigned int) {} operator delete(void *,unsigned __int64)8void __cdecl operator delete(void *,unsigned __int64) {} 9 10 // All calling conventions that appear in normal code. cc_cdecl()11int __cdecl cc_cdecl() { return 42; } cc_stdcall()12int __stdcall cc_stdcall() { return 42; } cc_fastcall()13int __fastcall cc_fastcall() { return 42; } cc_vectorcall()14int __vectorcall cc_vectorcall() { return 42; } 15 16 17 struct Struct { StructStruct18 Struct() {} // constructor 19 cc_thiscallStruct20 int __thiscall cc_thiscall() { return 42; } 21 MStruct22 void M() { } CMStruct23 void CM() const { } VMStruct24 void VM() volatile { } CVMStruct25 void CVM() const volatile { } 26 }; 27 builtin_one_param(int x)28int builtin_one_param(int x) { return 42; } builtin_two_params(int x,char y)29int builtin_two_params(int x, char y) { return 42; } 30 struct_one_param(Struct S)31void struct_one_param(Struct S) { } 32 modified_builtin_param(const int X)33void modified_builtin_param(const int X) { } modified_struct_param(const Struct S)34void modified_struct_param(const Struct S) { } 35 pointer_builtin_param(int * X)36void pointer_builtin_param(int *X) { } pointer_struct_param(Struct * S)37void pointer_struct_param(Struct *S) { } 38 39 modified_pointer_builtin_param(const int * X)40void modified_pointer_builtin_param(const int *X) { } modified_pointer_struct_param(const Struct * S)41void modified_pointer_struct_param(const Struct *S) { } 42 rvo()43Struct rvo() { return Struct(); } 44 45 struct Base1 { ~Base1Base146 virtual ~Base1() {} 47 }; 48 49 struct Base2 : public virtual Base1 { }; 50 51 struct Derived : public virtual Base1, public Base2 { 52 }; 53 54 main()55int main() { 56 cc_cdecl(); 57 cc_stdcall(); 58 cc_fastcall(); 59 Struct().cc_thiscall(); 60 cc_vectorcall(); 61 62 builtin_one_param(42); 63 builtin_two_params(42, 'x'); 64 struct_one_param(Struct{}); 65 66 modified_builtin_param(42); 67 modified_struct_param(Struct()); 68 69 pointer_builtin_param(nullptr); 70 pointer_struct_param(nullptr); 71 72 73 modified_pointer_builtin_param(nullptr); 74 modified_pointer_struct_param(nullptr); 75 76 Struct S = rvo(); 77 78 Derived D; 79 return 42; 80 } 81