From: Eli Friedman Date: Tue, 3 Aug 2010 17:34:19 +0000 (+0000) Subject: PR7795: Fix the definition of __WCHAR_MAX__ with -fshort-wchar. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d832436e9cd9223cbad66c5ca9ac87ed5c8560c;p=clang PR7795: Fix the definition of __WCHAR_MAX__ with -fshort-wchar. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110126 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index e5a4169502..88feca953a 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -173,7 +173,7 @@ static void DefineTypeSize(llvm::StringRef MacroName, unsigned TypeWidth, assert(TypeWidth != 1); MaxVal = ~0ULL >> (65-TypeWidth); } else - MaxVal = ~0LL >> (64-TypeWidth); + MaxVal = ~0ULL >> (64-TypeWidth); Builder.defineMacro(MacroName, llvm::Twine(MaxVal) + ValSuffix); } diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 8283671b66..4ebaddfa3f 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -117,6 +117,13 @@ // SCHAR-NOT:#define __UNSIGNED_CHAR__ // SCHAR:#define __clang__ 1 // +// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck -check-prefix SHORTWCHAR %s +// +// SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2 +// SHORTWCHAR: #define __WCHAR_MAX__ 65535U +// SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short +// SHORTWCHAR: #define __WCHAR_WIDTH__ 16 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s // // ARM:#define __APCS_32__ 1