[cfe-commits] r140608 - in /cfe/trunk: lib/Lex/LiteralSupport.cpp test/Lexer/utf8-char-literal.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 27 10:00:18 PDT 2011
Author: dgregor
Date: Tue Sep 27 12:00:18 2011
New Revision: 140608
URL: http://llvm.org/viewvc/llvm-project?rev=140608&view=rev
Log:
When parsing a character literal, extract the characters from the
buffer as an 'unsigned char', so that integer promotion doesn't
sign-extend character values > 127 into oblivion. Fixes
<rdar://problem/10188919>.
Added:
cfe/trunk/test/Lexer/utf8-char-literal.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=140608&r1=140607&r2=140608&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Sep 27 12:00:18 2011
@@ -784,7 +784,7 @@
// Is this a Universal Character Name escape?
if (begin[0] != '\\') // If this is a normal character, consume it.
- ResultChar = *begin++;
+ ResultChar = (unsigned char)*begin++;
else { // Otherwise, this is an escape character.
unsigned CharWidth = getCharWidth(Kind, PP.getTargetInfo());
// Check for UCN.
Added: cfe/trunk/test/Lexer/utf8-char-literal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/utf8-char-literal.cpp?rev=140608&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/utf8-char-literal.cpp (added)
+++ cfe/trunk/test/Lexer/utf8-char-literal.cpp Tue Sep 27 12:00:18 2011
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -fsyntax-only -verify %s
+
+int array0[u'ñ' == u'\xf1'? 1 : -1];
+int array1['ñ' != u'\xf1'? 1 : -1];
More information about the cfe-commits
mailing list