xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/microsoft-call-conv.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm < %s | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm -mrtd < %s | FileCheck %s
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm -fms-compatibility < %s
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc void __fastcall f1(void);
6*f4a2713aSLionel Sambuc void __stdcall f2(void);
7*f4a2713aSLionel Sambuc void __thiscall f3(void);
8*f4a2713aSLionel Sambuc void __fastcall f4(void) {
9*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_fastcallcc void @f4()
10*f4a2713aSLionel Sambuc   f1();
11*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @f1()
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc void __stdcall f5(void) {
14*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_stdcallcc void @f5()
15*f4a2713aSLionel Sambuc   f2();
16*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void @f2()
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc void __thiscall f6(void) {
19*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_thiscallcc void @f6()
20*f4a2713aSLionel Sambuc   f3();
21*f4a2713aSLionel Sambuc // CHECK: call x86_thiscallcc void @f3()
22*f4a2713aSLionel Sambuc }
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // PR5280
25*f4a2713aSLionel Sambuc void (__fastcall *pf1)(void) = f1;
26*f4a2713aSLionel Sambuc void (__stdcall *pf2)(void) = f2;
27*f4a2713aSLionel Sambuc void (__thiscall *pf3)(void) = f3;
28*f4a2713aSLionel Sambuc void (__fastcall *pf4)(void) = f4;
29*f4a2713aSLionel Sambuc void (__stdcall *pf5)(void) = f5;
30*f4a2713aSLionel Sambuc void (__thiscall *pf6)(void) = f6;
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc int main(void) {
33*f4a2713aSLionel Sambuc     f4(); f5(); f6();
34*f4a2713aSLionel Sambuc     // CHECK: call x86_fastcallcc void @f4()
35*f4a2713aSLionel Sambuc     // CHECK: call x86_stdcallcc void @f5()
36*f4a2713aSLionel Sambuc     // CHECK: call x86_thiscallcc void @f6()
37*f4a2713aSLionel Sambuc     pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
38*f4a2713aSLionel Sambuc     // CHECK: call x86_fastcallcc void %{{.*}}()
39*f4a2713aSLionel Sambuc     // CHECK: call x86_stdcallcc void %{{.*}}()
40*f4a2713aSLionel Sambuc     // CHECK: call x86_thiscallcc void %{{.*}}()
41*f4a2713aSLionel Sambuc     // CHECK: call x86_fastcallcc void %{{.*}}()
42*f4a2713aSLionel Sambuc     // CHECK: call x86_stdcallcc void %{{.*}}()
43*f4a2713aSLionel Sambuc     // CHECK: call x86_thiscallcc void %{{.*}}()
44*f4a2713aSLionel Sambuc     return 0;
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc // PR7117
48*f4a2713aSLionel Sambuc void __stdcall f7(foo) int foo; {}
49*f4a2713aSLionel Sambuc void f8(void) {
50*f4a2713aSLionel Sambuc   f7(0);
51*f4a2713aSLionel Sambuc   // CHECK: call x86_stdcallcc void @f7(i32 0)
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc // PR12535
55*f4a2713aSLionel Sambuc void __fastcall f9(int x, int y) {};
56*f4a2713aSLionel Sambuc // WIN: define x86_fastcallcc void @f9({{.*}})
57*f4a2713aSLionel Sambuc void __fastcall f10(int x, ...) {};
58*f4a2713aSLionel Sambuc // WIN: define void @f10({{.*}})
59*f4a2713aSLionel Sambuc void __stdcall f11(int x, ...) {};
60*f4a2713aSLionel Sambuc // WIN: define void @f11({{.*}})
61