81 lines · cpp
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 off5void *__purecall = 0;6 7void __cdecl operator delete(void *,unsigned int) {}8void __cdecl operator delete(void *,unsigned __int64) {}9 10// All calling conventions that appear in normal code.11int __cdecl cc_cdecl() { return 42; }12int __stdcall cc_stdcall() { return 42; }13int __fastcall cc_fastcall() { return 42; }14int __vectorcall cc_vectorcall() { return 42; }15 16 17struct Struct {18 Struct() {} // constructor19 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 28int builtin_one_param(int x) { return 42; }29int builtin_two_params(int x, char y) { return 42; }30 31void struct_one_param(Struct S) { }32 33void modified_builtin_param(const int X) { }34void modified_struct_param(const Struct S) { }35 36void pointer_builtin_param(int *X) { }37void pointer_struct_param(Struct *S) { }38 39 40void modified_pointer_builtin_param(const int *X) { }41void modified_pointer_struct_param(const Struct *S) { }42 43Struct rvo() { return Struct(); }44 45struct Base1 {46 virtual ~Base1() {}47};48 49struct Base2 : public virtual Base1 { };50 51struct Derived : public virtual Base1, public Base2 {52};53 54 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