xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/vararg-non-pod-ms-compat.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -Wno-error=non-pod-varargs -triple i686-pc-win32 -fms-compatibility -emit-llvm -o - %s | FileCheck %s -check-prefix=X86 -check-prefix=CHECK
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -Wno-error=non-pod-varargs -triple x86_64-pc-win32 -fms-compatibility -emit-llvm -o - %s | FileCheck %s -check-prefix=X64 -check-prefix=CHECK
3*0a6a1f1dSLionel Sambuc 
4*0a6a1f1dSLionel Sambuc struct X {
5*0a6a1f1dSLionel Sambuc   X();
6*0a6a1f1dSLionel Sambuc   ~X();
7*0a6a1f1dSLionel Sambuc   int data;
8*0a6a1f1dSLionel Sambuc };
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc void vararg(...);
11*0a6a1f1dSLionel Sambuc 
test(X x)12*0a6a1f1dSLionel Sambuc void test(X x) {
13*0a6a1f1dSLionel Sambuc   // CHECK-LABEL: define void @"\01?test@@YAXUX@@@Z"
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc   // X86: %[[argmem:[^ ]*]] = alloca inalloca <{ %struct.X }>
16*0a6a1f1dSLionel Sambuc   // X86: call void (<{ %struct.X }>*, ...)* bitcast (void (...)* @"\01?vararg@@YAXZZ" to void (<{ %struct.X }>*, ...)*)(<{ %struct.X }>* inalloca %[[argmem]])
17*0a6a1f1dSLionel Sambuc 
18*0a6a1f1dSLionel Sambuc   // X64: alloca %struct.X
19*0a6a1f1dSLionel Sambuc 
20*0a6a1f1dSLionel Sambuc   // X64: %[[agg:[^ ]*]] = alloca %struct.X
21*0a6a1f1dSLionel Sambuc   // X64: %[[valptr:[^ ]*]] = getelementptr %struct.X* %[[agg]], i32 0, i32 0
22*0a6a1f1dSLionel Sambuc   // X64: %[[val:[^ ]*]] = load i32* %[[valptr]]
23*0a6a1f1dSLionel Sambuc   // X64: call void (...)* @"\01?vararg@@YAXZZ"(i32 %[[val]])
24*0a6a1f1dSLionel Sambuc 
25*0a6a1f1dSLionel Sambuc   // CHECK-NOT: llvm.trap
26*0a6a1f1dSLionel Sambuc   vararg(x);
27*0a6a1f1dSLionel Sambuc   // CHECK: ret void
28*0a6a1f1dSLionel Sambuc }
29