diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-03-09 23:56:02 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-03-09 23:56:02 +0000 |
commit | 0093e12513c5c896434915d5e9126f51b780aa61 (patch) | |
tree | 4ba4f0eaf849ce25a1e9b23f1876f4a5c4201a9a /lib/Lex | |
parent | 0b91cc47a5642de2e1f567fe0f29420acdcdebbe (diff) |
When lexing in C11 mode, accept unicode character and string literals, per C11
6.4.4.4/1 and 6.4.5/1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/Lexer.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index e18953d448..e6cc8b929c 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -1629,7 +1629,8 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, if (!isLexingRawMode() && (Kind == tok::utf8_string_literal || Kind == tok::utf16_string_literal || - Kind == tok::utf32_string_literal)) + Kind == tok::utf32_string_literal) && + getLangOpts().CPlusPlus) Diag(BufferPtr, diag::warn_cxx98_compat_unicode_literal); char C = getAndAdvanceChar(CurPtr, Result); @@ -1794,7 +1795,8 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr, const char *NulCharacter = 0; // Does this character contain the \0 character? if (!isLexingRawMode() && - (Kind == tok::utf16_char_constant || Kind == tok::utf32_char_constant)) + (Kind == tok::utf16_char_constant || Kind == tok::utf32_char_constant) && + getLangOpts().CPlusPlus) Diag(BufferPtr, diag::warn_cxx98_compat_unicode_literal); char C = getAndAdvanceChar(CurPtr, Result); @@ -2848,11 +2850,11 @@ LexNextToken: MIOpt.ReadToken(); return LexNumericConstant(Result, CurPtr); - case 'u': // Identifier (uber) or C++0x UTF-8 or UTF-16 string literal + case 'u': // Identifier (uber) or C11/C++11 UTF-8 or UTF-16 string literal // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); - if (LangOpts.CPlusPlus11) { + if (LangOpts.CPlusPlus11 || LangOpts.C11) { Char = getCharAndSize(CurPtr, SizeTmp); // UTF-16 string literal @@ -2866,7 +2868,8 @@ LexNextToken: tok::utf16_char_constant); // UTF-16 raw string literal - if (Char == 'R' && getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') + if (Char == 'R' && LangOpts.CPlusPlus11 && + getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') return LexRawStringLiteral(Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result), @@ -2882,7 +2885,7 @@ LexNextToken: SizeTmp2, Result), tok::utf8_string_literal); - if (Char2 == 'R') { + if (Char2 == 'R' && LangOpts.CPlusPlus11) { unsigned SizeTmp3; char Char3 = getCharAndSize(CurPtr + SizeTmp + SizeTmp2, SizeTmp3); // UTF-8 raw string literal @@ -2900,11 +2903,11 @@ LexNextToken: // treat u like the start of an identifier. return LexIdentifier(Result, CurPtr); - case 'U': // Identifier (Uber) or C++0x UTF-32 string literal + case 'U': // Identifier (Uber) or C11/C++11 UTF-32 string literal // Notify MIOpt that we read a non-whitespace/non-comment token. MIOpt.ReadToken(); - if (LangOpts.CPlusPlus11) { + if (LangOpts.CPlusPlus11 || LangOpts.C11) { Char = getCharAndSize(CurPtr, SizeTmp); // UTF-32 string literal @@ -2918,7 +2921,8 @@ LexNextToken: tok::utf32_char_constant); // UTF-32 raw string literal - if (Char == 'R' && getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') + if (Char == 'R' && LangOpts.CPlusPlus11 && + getCharAndSize(CurPtr + SizeTmp, SizeTmp2) == '"') return LexRawStringLiteral(Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result), |