diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-27 20:12:04 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-27 20:12:04 +0000 |
commit | bfec916e5fc40f22ac11267e78a024cd8dcf3bbf (patch) | |
tree | 7a4ac2f001bce397ed206c2a57ca28fc42507c22 /lib | |
parent | 1df08370da6fb4578272295aabfacfb12e1d40f9 (diff) |
PR15067: Don't assert when a UCN appears in a C90 file.
Unfortunately, we can't accept the UCN as an extension because we're
required to treat it as two tokens for preprocessing purposes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/Lexer.cpp | 9 | ||||
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 429780eaea..91c4f66403 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -2698,8 +2698,6 @@ bool Lexer::isCodeCompletionPoint(const char *CurPtr) const { uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc, Token *Result) { - assert(LangOpts.CPlusPlus || LangOpts.C99); - unsigned CharSize; char Kind = getCharAndSize(StartPtr, CharSize); @@ -2711,6 +2709,11 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc, else return 0; + if (!LangOpts.CPlusPlus && !LangOpts.C99) { + Diag(SlashLoc, diag::warn_ucn_not_valid_in_c89); + return 0; + } + const char *CurPtr = StartPtr + CharSize; const char *KindLoc = &CurPtr[-1]; @@ -2737,7 +2740,7 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc, } } } - + return 0; } diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 1647aa5381..09a94a1143 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -277,7 +277,7 @@ static bool ProcessUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf, if (!Features.CPlusPlus && !Features.C99 && Diags) Diag(Diags, Features, Loc, ThisTokBegin, UcnBegin, ThisTokBuf, - diag::warn_ucn_not_valid_in_c89); + diag::warn_ucn_not_valid_in_c89_literal); return true; } |