Don't warn about escaped newlines in // comments if the next line is also

a // comment, this reduces noise in the llvm testsuite.

llvm-svn: 39636
This commit is contained in:
Chris Lattner 2007-06-09 06:07:22 +00:00
parent 736ed5dfb8
commit ff591e24eb
1 changed files with 13 additions and 2 deletions

View File

@ -643,10 +643,21 @@ bool Lexer::SkipBCPLComment(LexerToken &Result, const char *CurPtr) {
C = getAndAdvanceChar(CurPtr, Result);
// If we read multiple characters, and one of those characters was a \r or
// \n, then we had an escaped newline within the comment. Emit diagnostic.
if (CurPtr != OldPtr+1) {
// \n, then we had an escaped newline within the comment. Emit diagnostic
// unless the next line is also a // comment.
if (CurPtr != OldPtr+1 && C != '/' && CurPtr[0] != '/') {
for (; OldPtr != CurPtr; ++OldPtr)
if (OldPtr[0] == '\n' || OldPtr[0] == '\r') {
// Okay, we found a // comment that ends in a newline, if the next
// line is also a // comment, but has spaces, don't emit a diagnostic.
if (isspace(C)) {
const char *ForwardPtr = CurPtr;
while (isspace(*ForwardPtr)) // Skip whitespace.
++ForwardPtr;
if (ForwardPtr[0] == '/' && ForwardPtr[1] == '/')
break;
}
Diag(OldPtr-1, diag::ext_multi_line_bcpl_comment);
break;
}