]> granicus.if.org Git - clang/commitdiff
Fix a regression in wide character codegen. See PR11369.
authorNico Weber <nicolasweber@gmx.de>
Mon, 14 Nov 2011 05:17:37 +0000 (05:17 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 14 Nov 2011 05:17:37 +0000 (05:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144521 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp
test/CodeGen/string-literal-unicode-conversion.c

index 16f02f41306bca8465fcca3049e645a8acb1f5ee..296a89461f8263855ead4dc40e8ebc3930390bea 100644 (file)
@@ -1095,13 +1095,13 @@ void StringLiteralParser::init(const Token *StringToks, unsigned NumStringToks){
           // FIXME: Make the type of the result buffer correct instead of
           // using reinterpret_cast.
           UTF32 *ResultWidePtr = reinterpret_cast<UTF32*>(ResultPtr);
-          *ResultWidePtr = ResultChar & 0xFF;
+          *ResultWidePtr = ResultChar;
           ResultPtr += 4;
         } else if (CharByteWidth == 2) {
           // FIXME: Make the type of the result buffer correct instead of
           // using reinterpret_cast.
           UTF16 *ResultWidePtr = reinterpret_cast<UTF16*>(ResultPtr);
-          *ResultWidePtr = ResultChar & 0xFF;
+          *ResultWidePtr = ResultChar & 0xFFFF;
           ResultPtr += 2;
         } else {
           assert(CharByteWidth == 1 && "Unexpected char width");
index 7431d9a13d60886129d5ba2a03d90dbafc8bcead..3e5b7fb041129ec938acfb0b4c887a56e9231bb7 100644 (file)
@@ -29,6 +29,11 @@ void f() {
   // CHECK-SHORTWCHAR: private unnamed_addr constant [6 x i16] [i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
   // CHECK-CPP0X: private unnamed_addr constant [6 x i32] [i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
   wchar_t const *b = L"Кошка";
+
+  // CHECK-C: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+  // CHECK-SHORTWCHAR: private unnamed_addr constant [4 x i16] [i16 20320, i16 22909, i16 768, i16 0], align 2
+  // CHECK-CPP0X: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+  wchar_t const *b2 = L"\x4f60\x597d\x10300";
   
 #if __cplusplus >= 201103L