[clang] 0fb97fd - [SystemZ][z/OS] Set default wchar_t type for zOS
Abhina Sreeskantharajan via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 05:03:10 PDT 2020
Author: Abhina Sreeskantharajan
Date: 2020-09-22T08:03:03-04:00
New Revision: 0fb97fd6a4f2ec9267a1f4d039ec8895c2460ab7
URL: https://github.com/llvm/llvm-project/commit/0fb97fd6a4f2ec9267a1f4d039ec8895c2460ab7
DIFF: https://github.com/llvm/llvm-project/commit/0fb97fd6a4f2ec9267a1f4d039ec8895c2460ab7.diff
LOG: [SystemZ][z/OS] Set default wchar_t type for zOS
Set the default wchar_t type on z/OS, and unsigned as the default.
Reviewed By: hubert.reinterpretcast, fanbo-meng
Differential Revision: https://reviews.llvm.org/D87624
Added:
Modified:
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/wchar-size.c
clang/test/Lexer/wchar-signedness.c
clang/test/Preprocessor/wchar_t.c
clang/test/Sema/wchar.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 0c06ac3cd035..e07067693054 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -776,7 +776,9 @@ class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo<Target> {
public:
ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
- : OSTargetInfo<Target>(Triple, Opts) {}
+ : OSTargetInfo<Target>(Triple, Opts) {
+ this->WCharType = TargetInfo::UnsignedInt;
+ }
};
void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8ce59f5ba580..0518dc21db73 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3409,8 +3409,8 @@ static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T,
} else {
bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
CmdArgs.push_back("-fwchar-type=int");
- if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+ if (T.isOSzOS() ||
+ (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD())))
CmdArgs.push_back("-fno-signed-wchar");
else
CmdArgs.push_back("-fsigned-wchar");
diff --git a/clang/test/CodeGen/wchar-size.c b/clang/test/CodeGen/wchar-size.c
index 28cd5d14d77a..75d8c47ac22a 100644
--- a/clang/test/CodeGen/wchar-size.c
+++ b/clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=LONG-WCHAR
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | FileCheck %s -check-prefix=SHORT-WCHAR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - -fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s -check-prefix=LONG-WCHAR
// Note: -fno-short-wchar implies the target default is used; so there is no
// need to test this separately here.
diff --git a/clang/test/Lexer/wchar-signedness.c b/clang/test/Lexer/wchar-signedness.c
index 1d8bc4d5dd03..ea46da015490 100644
--- a/clang/test/Lexer/wchar-signedness.c
+++ b/clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-X86
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck %s --check-prefix=CHECK-ZOS
// CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
// CHECK-X86: #define __WINT_UNSIGNED__ 1
// CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
// CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1
diff --git a/clang/test/Preprocessor/wchar_t.c b/clang/test/Preprocessor/wchar_t.c
index 9a7cade3963a..647bbc94389e 100644
--- a/clang/test/Preprocessor/wchar_t.c
+++ b/clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
// RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
// CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
// CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
diff --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c
index 6a4b75b39fd1..3170e363ff77 100644
--- a/clang/test/Sema/wchar.c
+++ b/clang/test/Sema/wchar.c
@@ -6,7 +6,7 @@ typedef __WCHAR_TYPE__ wchar_t;
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
|| defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
-#elif defined(__arm) || defined(__aarch64__)
+#elif defined(__arm) || defined(__aarch64__) || defined(__MVS__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun)
#if defined(__LP64__)
More information about the cfe-commits
mailing list