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 7 void __cdecl operator delete(void *,unsigned int) {} 8 void __cdecl operator delete(void *,unsigned __int64) {} 9 10 // All calling conventions that appear in normal code. 11 int __cdecl cc_cdecl() { return 42; } 12 int __stdcall cc_stdcall() { return 42; } 13 int __fastcall cc_fastcall() { return 42; } 14 int __vectorcall cc_vectorcall() { return 42; } 15 16 17 struct Struct { 18 Struct() {} // constructor 19 20 int __thiscall cc_thiscall() { return 42; } 21 22 void M() { } 23 void CM() const { } 24 void VM() volatile { } 25 void CVM() const volatile { } 26 }; 27 28 int builtin_one_param(int x) { return 42; } 29 int builtin_two_params(int x, char y) { return 42; } 30 31 void struct_one_param(Struct S) { } 32 33 void modified_builtin_param(const int X) { } 34 void modified_struct_param(const Struct S) { } 35 36 void pointer_builtin_param(int *X) { } 37 void pointer_struct_param(Struct *S) { } 38 39 40 void modified_pointer_builtin_param(const int *X) { } 41 void modified_pointer_struct_param(const Struct *S) { } 42 43 Struct rvo() { return Struct(); } 44 45 struct Base1 { 46 virtual ~Base1() {} 47 }; 48 49 struct Base2 : public virtual Base1 { }; 50 51 struct Derived : public virtual Base1, public Base2 { 52 }; 53 54 55 int 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