From 637eb77dedee82399318cc79bf631183e56159f6 Mon Sep 17 00:00:00 2001
From: Saleem Abdulrasool <compnerd@compnerd.org>
Date: Sun, 29 Jun 2014 23:05:41 +0000
Subject: [PATCH] Basic: correct the va_list type on Windows on ARM

Windows on ARM defines va_list as a typedef for char *.  Although the semantics
of argument passing for variadic functions matches AAPCS VFP, the wrapped
struct __va_list type is unused.  This makes the intrinsic definition for
va_list match that of Visual Studio.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212004 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Basic/Targets.cpp                  |  3 +++
 test/CodeGenCXX/windows-arm-valist.cpp | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 test/CodeGenCXX/windows-arm-valist.cpp

diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index dae4f767f87..34608f17a12 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -4231,6 +4231,9 @@ public:
     // 31: VFPv3 40: VFPv4
     Builder.defineMacro("_M_ARM_FP", "31");
   }
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+    return TargetInfo::CharPtrBuiltinVaList;
+  }
 };
 
 // Windows ARM + Itanium C++ ABI Target
diff --git a/test/CodeGenCXX/windows-arm-valist.cpp b/test/CodeGenCXX/windows-arm-valist.cpp
new file mode 100644
index 00000000000..6e31feddb2b
--- /dev/null
+++ b/test/CodeGenCXX/windows-arm-valist.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple thumbv7--windows-msvc -std=c++11 -fsyntax-only -fms-compatibility -x c++ %s
+
+#include <stdarg.h>
+
+template <typename lhs_, typename rhs_>
+struct is_same { enum { value = 0 }; };
+
+template <typename type_>
+struct is_same<type_, type_> { enum { value = 1 }; };
+
+void check() {
+  va_list va;
+  char *cp;
+  static_assert(is_same<decltype(va), decltype(cp)>::value,
+                "type mismatch for va_list");
+}
-- 
GitLab