summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/Lexer.cpp2
-rw-r--r--clang/test/Lexer/eof-include.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index a3b520b2632..3f89ea649cb 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1854,7 +1854,7 @@ bool Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) {
char C = getAndAdvanceChar(CurPtr, Result);
while (C != '>') {
// Skip escaped characters.
- if (C == '\\') {
+ if (C == '\\' && CurPtr < BufferEnd) {
// Skip the escaped character.
getAndAdvanceChar(CurPtr, Result);
} else if (C == '\n' || C == '\r' || // Newline.
diff --git a/clang/test/Lexer/eof-include.c b/clang/test/Lexer/eof-include.c
new file mode 100644
index 00000000000..6e537887188
--- /dev/null
+++ b/clang/test/Lexer/eof-include.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify
+// vim: set binary noeol:
+
+// This file intentionally ends without a \n on the last line. Make sure your
+// editor doesn't add one.
+
+// expected-error@+1{{expected "FILENAME" or <FILENAME>}}
+#include <\ \ No newline at end of file
OpenPOWER on IntegriCloud