diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-09-19 16:18:55 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-09-19 16:18:55 +0000 |
commit | 6183c6316d2187a4cbca23e7c3e07d36ef1edd8b (patch) | |
tree | a19d4a9936e9d8a1f77ee70d90a13cda4e2abda4 | |
parent | 5b476c5a9f6e250a4b4b2d18f6da839ca62dd458 (diff) | |
download | bcm5719-llvm-6183c6316d2187a4cbca23e7c3e07d36ef1edd8b.tar.gz bcm5719-llvm-6183c6316d2187a4cbca23e7c3e07d36ef1edd8b.zip |
Basic: correct `__WINT_TYPE__` on Windows
Windows uses `unsigned short` for `wint_t`. Correct the type definition as
vended by the compiler. This type is defined in corecrt.h and is
unconditionally typedef'ed. cl does not have an equivalent to `__WINT_TYPE__`
which is why this was never detected.
llvm-svn: 342557
-rw-r--r-- | clang/lib/Basic/Targets/OSTargets.h | 1 | ||||
-rw-r--r-- | clang/test/Preprocessor/init.c | 6 | ||||
-rw-r--r-- | clang/test/Preprocessor/woa-defaults.c | 2 | ||||
-rw-r--r-- | clang/test/Sema/format-strings-ms.c | 5 |
4 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index d0354784acf..48da6dc950a 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -643,6 +643,7 @@ public: WindowsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { this->WCharType = TargetInfo::UnsignedShort; + this->WIntType = TargetInfo::UnsignedShort; } }; diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 6e15bdc30a5..5a93f3b1fa3 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1553,7 +1553,7 @@ // AARCH64-MSVC: #define __SIZEOF_SHORT__ 2 // AARCH64-MSVC: #define __SIZEOF_SIZE_T__ 8 // AARCH64-MSVC: #define __SIZEOF_WCHAR_T__ 2 -// AARCH64-MSVC: #define __SIZEOF_WINT_T__ 4 +// AARCH64-MSVC: #define __SIZEOF_WINT_T__ 2 // AARCH64-MSVC: #define __SIZE_MAX__ 18446744073709551615ULL // AARCH64-MSVC: #define __SIZE_TYPE__ long long unsigned int // AARCH64-MSVC: #define __SIZE_WIDTH__ 64 @@ -1602,8 +1602,8 @@ // AARCH64-MSVC: #define __WCHAR_TYPE__ unsigned short // AARCH64-MSVC: #define __WCHAR_UNSIGNED__ 1 // AARCH64-MSVC: #define __WCHAR_WIDTH__ 16 -// AARCH64-MSVC: #define __WINT_TYPE__ int -// AARCH64-MSVC: #define __WINT_WIDTH__ 32 +// AARCH64-MSVC: #define __WINT_TYPE__ unsigned short +// AARCH64-MSVC: #define __WINT_WIDTH__ 16 // AARCH64-MSVC: #define __aarch64__ 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM %s diff --git a/clang/test/Preprocessor/woa-defaults.c b/clang/test/Preprocessor/woa-defaults.c index 4eef863b23a..97578239396 100644 --- a/clang/test/Preprocessor/woa-defaults.c +++ b/clang/test/Preprocessor/woa-defaults.c @@ -27,7 +27,7 @@ // CHECK: #define __SIZEOF_SHORT__ 2 // CHECK: #define __SIZEOF_SIZE_T__ 4 // CHECK: #define __SIZEOF_WCHAR_T__ 2 -// CHECK: #define __SIZEOF_WINT_T__ 4 +// CHECK: #define __SIZEOF_WINT_T__ 2 // CHECK: #define __SIZE_TYPE__ unsigned int // CHECK: #define __UINTPTR_TYPE__ unsigned int diff --git a/clang/test/Sema/format-strings-ms.c b/clang/test/Sema/format-strings-ms.c index 42676e7a4e0..9887b461f61 100644 --- a/clang/test/Sema/format-strings-ms.c +++ b/clang/test/Sema/format-strings-ms.c @@ -13,6 +13,7 @@ void non_iso_warning_test(__int32 i32, __int64 i64, wchar_t c, void *p) { printf("%I32d", i32); // expected-warning{{'I32' length modifier is not supported by ISO C}} printf("%I64d", i64); // expected-warning{{'I64' length modifier is not supported by ISO C}} printf("%wc", c); // expected-warning{{'w' length modifier is not supported by ISO C}} + // expected-warning@-1{{format specifies type 'wint_t' (aka 'unsigned short') but the argument has type 'wchar_t' (aka 'unsigned short')}} printf("%Z", p); // expected-warning{{'Z' conversion specifier is not supported by ISO C}} } @@ -35,7 +36,7 @@ void unsigned_test() { } void w_test(wchar_t c, wchar_t *s) { - printf("%wc", c); + printf("%wc", c); // expected-warning{{format specifies type 'wint_t' (aka 'unsigned short') but the argument has type 'wchar_t' (aka 'unsigned short')}} printf("%wC", c); printf("%C", c); printf("%ws", s); @@ -49,7 +50,7 @@ void w_test(wchar_t c, wchar_t *s) { scanf("%S", s); double bad; - printf("%wc", bad); // expected-warning{{format specifies type 'wint_t' (aka 'int') but the argument has type 'double'}} + printf("%wc", bad); // expected-warning{{format specifies type 'wint_t' (aka 'unsigned short') but the argument has type 'double'}} printf("%wC", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}} printf("%C", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}} printf("%ws", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}} |