Index: lib/Lex/Lexer.cpp =================================================================== --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -1854,7 +1854,7 @@ 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. Index: test/Lexer/eof-include.c =================================================================== --- /dev/null +++ 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 }} +#include <\ \ No newline at end of file