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:
Michael Wong 2015-02-24 13:34:20 +00:00
parent cec70130ac
commit 867eeb5861
3 changed files with 15 additions and 1 deletions

View File

@ -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()) {

View 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

View 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