[PATCH] D57831: AMDGPU: set wchar_t and wint_t to be unsigned short on windows

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 6 11:06:42 PST 2019

yaxunl created this revision.
yaxunl added a reviewer: b-sumner.
Herald added subscribers: t-tye, Anastasia, tpr, dstuttard, nhaehnle, wdng, jvesely, kzhuravl.

In MSVC wchar_t and wint_t are unsigned short. There is static_assert in MSVC headers checking that.

Since HIP and OpenCL share the same device library on windows, we have to define wchar_t and
wint_t to match MSVC on windows.

This should not affect OpenCL since OpenCL does not use wchar_t or wint_t.



Index: test/SemaCXX/amdgpu-wchar.cxx
--- /dev/null
+++ test/SemaCXX/amdgpu-wchar.cxx
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple amdgcn -std=c++11 %s
+typedef __WINT_TYPE__ wint_t;
+#if _WIN32
+static_assert(sizeof(wchar_t)==2, "fail");
+static_assert(sizeof(wint_t)==2, "fail");
+static_assert(sizeof(wchar_t)==4, "fail");
+static_assert(sizeof(wint_t)==4, "fail");
Index: lib/Basic/Targets/AMDGPU.cpp
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -260,6 +260,10 @@
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+#if _WIN32
+  WCharType = UnsignedShort;
+  WIntType = UnsignedShort;
 void AMDGPUTargetInfo::adjust(LangOptions &Opts) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57831.185595.patch
Type: text/x-patch
Size: 843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190206/ed4b784a/attachment.bin>

More information about the cfe-commits mailing list