mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 06:06:06 +00:00
Commit patch for PR19649. Set the correct sign of wide character for literals based on underlying type of wchar_t.
Reviewed: http://reviews.llvm.org/D7559 Patch by Rachel Craig; Test cases by Hubert Tong. llvm-svn: 230333
This commit is contained in:
parent
cec70130ac
commit
867eeb5861
@ -310,7 +310,9 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
|
||||
// Set the value.
|
||||
Val = Literal.getValue();
|
||||
// Set the signedness. UTF-16 and UTF-32 are always unsigned
|
||||
if (!Literal.isUTF16() && !Literal.isUTF32())
|
||||
if (Literal.isWide())
|
||||
Val.setIsUnsigned(!TargetInfo::isTypeSigned(TI.getWCharType()));
|
||||
else if (!Literal.isUTF16() && !Literal.isUTF32())
|
||||
Val.setIsUnsigned(!PP.getLangOpts().CharIsSigned);
|
||||
|
||||
if (Result.Val.getBitWidth() > Val.getBitWidth()) {
|
||||
|
6
clang/test/Preprocessor/pr19649-signed-wchar_t.c
Normal file
6
clang/test/Preprocessor/pr19649-signed-wchar_t.c
Normal file
@ -0,0 +1,6 @@
|
||||
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -x c %s
|
||||
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fno-signed-char -x c %s
|
||||
|
||||
#if (L'\0' - 1 > 0)
|
||||
# error "Unexpected expression evaluation result"
|
||||
#endif
|
6
clang/test/Preprocessor/pr19649-unsigned-wchar_t.c
Normal file
6
clang/test/Preprocessor/pr19649-unsigned-wchar_t.c
Normal file
@ -0,0 +1,6 @@
|
||||
// RUN: %clang_cc1 -triple i386-pc-cygwin -E -x c %s
|
||||
// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fshort-wchar -x c %s
|
||||
|
||||
#if (L'\0' - 1 < 0)
|
||||
# error "Unexpected expression evaluation result"
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user