diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-11-08 06:08:42 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-11-08 06:08:42 +0000 |
commit | 3e3a705062fe343dc397c0bf623aa383f14ce07c (patch) | |
tree | c22a037420f5961f40672567865afc4591809a78 /clang/lib/Lex/Lexer.cpp | |
parent | cf29675d9501cfff2a37acb8af3eefa6cbba19c1 (diff) | |
download | llvm-3e3a705062fe343dc397c0bf623aa383f14ce07c.zip llvm-3e3a705062fe343dc397c0bf623aa383f14ce07c.tar.gz llvm-3e3a705062fe343dc397c0bf623aa383f14ce07c.tar.bz2 |
[c++1z] Support for u8 character literals.
llvm-svn: 221576
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 0aaad9b..c2e9716 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1889,17 +1889,20 @@ bool Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) { /// LexCharConstant - Lex the remainder of a character constant, after having -/// lexed either ' or L' or u' or U'. +/// lexed either ' or L' or u8' or u' or U'. bool Lexer::LexCharConstant(Token &Result, const char *CurPtr, tok::TokenKind Kind) { // Does this character contain the \0 character? const char *NulCharacter = nullptr; - if (!isLexingRawMode() && - (Kind == tok::utf16_char_constant || Kind == tok::utf32_char_constant)) - Diag(BufferPtr, getLangOpts().CPlusPlus - ? diag::warn_cxx98_compat_unicode_literal - : diag::warn_c99_compat_unicode_literal); + if (!isLexingRawMode()) { + if (Kind == tok::utf16_char_constant || Kind == tok::utf32_char_constant) + Diag(BufferPtr, getLangOpts().CPlusPlus + ? diag::warn_cxx98_compat_unicode_literal + : diag::warn_c99_compat_unicode_literal); + else if (Kind == tok::utf8_char_constant) + Diag(BufferPtr, diag::warn_cxx14_compat_u8_character_literal); + } char C = getAndAdvanceChar(CurPtr, Result); if (C == '\'') { @@ -3068,6 +3071,11 @@ LexNextToken: ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result), tok::utf8_string_literal); + if (Char2 == '\'' && LangOpts.CPlusPlus1z) + return LexCharConstant( + Result, ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), + SizeTmp2, Result), + tok::utf8_char_constant); if (Char2 == 'R' && LangOpts.CPlusPlus11) { unsigned SizeTmp3; |