Adding 64-bit test case as suggested by Reid.

http://reviews.llvm.org/D5492

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGenCXX/vararg-non-pod-ms-compat.cpp
  test/SemaCXX/vararg-non-pod.cpp
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -875,7 +875,8 @@
 
   // Diagnostics regarding non-POD argument types are
   // emitted along with format string checking in Sema::CheckFunctionCall().
-  if (isValidVarArgType(E->getType()) == VAK_Undefined) {
+  if (isValidVarArgType(E->getType()) == VAK_Undefined &&
+      !LangOpts.MSVCCompat) {
     // Turn this into a trap.
     CXXScopeSpec SS;
     SourceLocation TemplateKWLoc;
Index: test/CodeGenCXX/vararg-non-pod-ms-compat.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/vararg-non-pod-ms-compat.cpp
@@ -0,0 +1,26 @@
+// 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
+// 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
+
+struct X {
+  X();
+  ~X();
+  int data;
+};
+
+void vararg(...);
+
+void test(X x) {
+  // CHECK-LABEL: define void @"\01?test@@YAXUX@@@Z"
+
+  // X86: %[[argmem:[^ ]*]] = alloca inalloca <{ %struct.X }>
+  // X86: call void (<{ %struct.X }>*, ...)* bitcast (void (...)* @"\01?vararg@@YAXZZ" to void (<{ %struct.X }>*, ...)*)(<{ %struct.X }>* inalloca %[[argmem]])
+
+  // X64: %[[valptr:[^ ]*]] = getelementptr %struct.X* %{{[^ ]*}}, i32 0, i32 0
+  // X64: %[[val:[^ ]*]] = load i32* %[[valptr]]
+  // X64: call void (...)* @"\01?vararg@@YAXZZ"(i32 %[[val]])
+
+  // CHECK-NOT: llvm.trap
+  vararg(x);
+  // CHECK: ret void
+}
+
Index: test/SemaCXX/vararg-non-pod.cpp
===================================================================
--- test/SemaCXX/vararg-non-pod.cpp
+++ test/SemaCXX/vararg-non-pod.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs
 
+// Check that the warning is still there under -fms-compatibility.
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs -fms-compatibility
+
 extern char version[];
 
 class C {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to