diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-04-05 00:26:41 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-04-05 00:26:41 +0000 |
| commit | ecdaf40c9e12f575326ff28f73cd9dc19f3e5d7f (patch) | |
| tree | 91ccceb7f140c4c857d074bed68a568b21929ca7 | |
| parent | fff33a3cdfa344cadc69f9c3114165542701f862 (diff) | |
| download | bcm5719-llvm-ecdaf40c9e12f575326ff28f73cd9dc19f3e5d7f.tar.gz bcm5719-llvm-ecdaf40c9e12f575326ff28f73cd9dc19f3e5d7f.zip | |
fix rdar://6757323, where an escaped newline in a // comment
was causing the char after the newline to get eaten.
llvm-svn: 68430
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 8 | ||||
| -rw-r--r-- | clang/test/Lexer/comment-escape.c | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 3a3e86a3cf1..059afe21822 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -848,6 +848,14 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) { LexingRawMode = true; C = getAndAdvanceChar(CurPtr, Result); LexingRawMode = OldRawMode; + + // If the char that we finally got was a \n, then we must have had something + // like \<newline><newline>. We don't want to have consumed the second + // newline, we want CurPtr, to end up pointing to it down below. + if (C == '\n' || C == '\r') { + --CurPtr; + C = 'x'; // doesn't matter what this is. + } // 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 diff --git a/clang/test/Lexer/comment-escape.c b/clang/test/Lexer/comment-escape.c new file mode 100644 index 00000000000..c568cd611f1 --- /dev/null +++ b/clang/test/Lexer/comment-escape.c @@ -0,0 +1,6 @@ +// RUN: clang -fsyntax-only %s +// rdar://6757323 +// foo \ + +#define blork 32 + |

