summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-06-13 05:41:29 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-06-13 05:41:29 +0000
commit0948d93b7fdd571236536eff218aaadfaac5558e (patch)
tree11d5a94be51ae49a06b350e94151af77792f9cb0 /clang
parent4060f774625d4539f4143993fe7ca990a5de512a (diff)
downloadbcm5719-llvm-0948d93b7fdd571236536eff218aaadfaac5558e.tar.gz
bcm5719-llvm-0948d93b7fdd571236536eff218aaadfaac5558e.zip
Fix off-by-one error in UTF-16 encoding: don't try to use a surrogate pair for U+FFFF.
llvm-svn: 158391
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/LiteralSupport.cpp2
-rw-r--r--clang/test/Lexer/char-literal.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 2930d6a5ff0..9b0bc703454 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -322,7 +322,7 @@ static void EncodeUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
// using reinterpret_cast.
UTF16 *ResultPtr = reinterpret_cast<UTF16*>(ResultBuf);
- if (UcnVal < (UTF32)0xFFFF) {
+ if (UcnVal <= (UTF32)0xFFFF) {
*ResultPtr = UcnVal;
ResultBuf += 2;
return;
diff --git a/clang/test/Lexer/char-literal.cpp b/clang/test/Lexer/char-literal.cpp
index 5dc53608f8f..8556d468cba 100644
--- a/clang/test/Lexer/char-literal.cpp
+++ b/clang/test/Lexer/char-literal.cpp
@@ -22,3 +22,6 @@ char m = '👿'; // expected-error {{character too large for enclosing character
char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
+
+char16_t p[2] = u"\U0000FFFF";
+char16_t q[2] = u"\U00010000"; // expected-error {{too long}}
OpenPOWER on IntegriCloud