]> granicus.if.org Git - clang/commitdiff
Remove a dead argument to ProcessUCNEscape.
authorChris Lattner <sabre@nondot.org>
Tue, 15 Jun 2010 18:06:43 +0000 (18:06 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 15 Jun 2010 18:06:43 +0000 (18:06 +0000)
Fix string concatenation to treat escapes in concatenated strings that
are wide because of other string chunks to process the escapes as wide
themselves.  Before we would warn about and miscompile the attached testcase.

This fixes rdar://8040728 - miscompile + warning: hex escape sequence out of range

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106012 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp
test/SemaCXX/wchar_t.cpp

index ff4d28f1288abab0f59f841e93b1205f69ff5d64..b8fd3ce9e9ffa7da3000ab6c98da71f38df37381 100644 (file)
@@ -169,9 +169,8 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
 /// we will likely rework our support for UCN's.
 static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
                              char *&ResultBuf, bool &HadError,
-                             SourceLocation Loc, bool IsWide, Preprocessor &PP,
-                             bool Complain)
-{
+                             SourceLocation Loc, Preprocessor &PP,
+                             bool Complain) {
   // FIXME: Add a warning - UCN's are only valid in C++ & C99.
   // FIXME: Handle wide strings.
 
@@ -835,11 +834,8 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
     // TODO: Input character set mapping support.
 
     // Skip L marker for wide strings.
-    bool ThisIsWide = false;
-    if (ThisTokBuf[0] == 'L') {
+    if (ThisTokBuf[0] == 'L')
       ++ThisTokBuf;
-      ThisIsWide = true;
-    }
 
     assert(ThisTokBuf[0] == '"' && "Expected quote, lexer broken?");
     ++ThisTokBuf;
@@ -884,14 +880,13 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
       // Is this a Universal Character Name escape?
       if (ThisTokBuf[1] == 'u' || ThisTokBuf[1] == 'U') {
         ProcessUCNEscape(ThisTokBuf, ThisTokEnd, ResultPtr,
-                         hadError, StringToks[i].getLocation(), ThisIsWide, PP,
-                         Complain);
+                         hadError, StringToks[i].getLocation(), PP, Complain);
         continue;
       }
       // Otherwise, this is a non-UCN escape character.  Process it.
       unsigned ResultChar = ProcessCharEscape(ThisTokBuf, ThisTokEnd, hadError,
                                               StringToks[i].getLocation(),
-                                              ThisIsWide, PP, Complain);
+                                              AnyWide, PP, Complain);
 
       // Note: our internal rep of wide char tokens is always little-endian.
       *ResultPtr++ = ResultChar & 0xFF;
index 789dbf643863fccc31c813cfe166f8bb08fdf254..f9d7b614329ccf4920c1131becb1a7ace002c0c8 100644 (file)
@@ -25,3 +25,8 @@ int t(void) {
   basic_string<wchar_t>() + L'-';
   return (0);
 }
+
+
+// rdar://8040728
+wchar_t in[] = L"\x434" "\x434";  // No warning
+