]> granicus.if.org Git - clang/commitdiff
don't read off the front of the buffer. Thanks to Sam for pointing this out.
authorChris Lattner <sabre@nondot.org>
Fri, 11 Apr 2008 16:20:41 +0000 (16:20 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 11 Apr 2008 16:20:41 +0000 (16:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49535 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp

index 98bbb386305d24684ac2690ff57f888328db4a37..e3daf31267139d9d369cb11840721af9c06e25cf 100644 (file)
@@ -1142,7 +1142,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
   }
   
   // If the file was empty or didn't end in a newline, issue a pedwarn.
-  if (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')
+  if (CurPtr == BufferStart || (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
     Diag(BufferEnd, diag::ext_no_newline_eof);
   
   BufferPtr = CurPtr;