]> granicus.if.org Git - clang/commitdiff
Target: fix wchar_t definition for Windows on ARM
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 4 May 2014 01:56:04 +0000 (01:56 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 4 May 2014 01:56:04 +0000 (01:56 +0000)
Windows on ARM uses AAPCS, but has some deviations.  wchar_t remains an unsigned
short on WoA, which does not conform to AAPCS.  Ensure that wchar_t is defined
accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207929 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/Preprocessor/woa-wchar_t.c [new file with mode: 0644]

index 5effe027e24c2802a583caf36330e94864cd8fe0..4bcdb373413a7b1f23dab642e3aa45323a155199 100644 (file)
@@ -3784,11 +3784,18 @@ class ARMTargetInfo : public TargetInfo {
     else
       SizeType = UnsignedInt;
 
-    if (T.getOS() == llvm::Triple::NetBSD) {
+    switch (T.getOS()) {
+    case llvm::Triple::NetBSD:
       WCharType = SignedInt;
-    } else {
+      break;
+    case llvm::Triple::Win32:
+      WCharType = UnsignedShort;
+      break;
+    case llvm::Triple::Linux:
+    default:
       // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int.
       WCharType = UnsignedInt;
+      break;
     }
 
     UseBitFieldTypeAlignment = true;
diff --git a/test/Preprocessor/woa-wchar_t.c b/test/Preprocessor/woa-wchar_t.c
new file mode 100644 (file)
index 0000000..eb9a862
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -dM -triple armv7-windows -E %s | FileCheck %s
+// RUN: %clang_cc1 -dM -fno-signed-char -triple armv7-windows -E %s | FileCheck %s
+
+// CHECK: #define __WCHAR_TYPE__ unsigned short
+