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