aboutsummaryrefslogtreecommitdiff
path: root/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-21 23:43:37 +0000
committerChris Lattner <sabre@nondot.org>2007-07-21 23:43:37 +0000
commit8146b6851e873eab71341f1b1d3198894bc4c0ac (patch)
tree19e7e9b31293b8ec14a4965de00b2c36e9d8eade /Lex/Lexer.cpp
parent731ec57bd3bb1cf7cb26423fb56bac2dae546efc (diff)
Fix a lexer bug where we incorrectly rejected
int i = /*/ */ 1; Thanks to Neil for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Lexer.cpp')
-rw-r--r--Lex/Lexer.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lex/Lexer.cpp b/Lex/Lexer.cpp
index 1518d8895c..e92fc94da2 100644
--- a/Lex/Lexer.cpp
+++ b/Lex/Lexer.cpp
@@ -817,13 +817,24 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
// we find it, check to see if it was preceeded by a *. This common
// optimization helps people who like to put a lot of * characters in their
// comments.
- unsigned char C = *CurPtr++;
+
+ // The first character we get with newlines and trigraphs skipped to handle
+ // the degenerate /*/ case below correctly if the * has an escaped newline
+ // after it.
+ unsigned CharSize;
+ unsigned char C = getCharAndSize(CurPtr, CharSize);
+ CurPtr += CharSize;
if (C == 0 && CurPtr == BufferEnd+1) {
Diag(BufferPtr, diag::err_unterminated_block_comment);
BufferPtr = CurPtr-1;
return true;
}
+ // Check to see if the first character after the '/*' is another /. If so,
+ // then this slash does not end the block comment, it is part of it.
+ if (C == '/')
+ C = *CurPtr++;
+
while (1) {
// Skip over all non-interesting characters until we find end of buffer or a
// (probably ending) '/' character.