[cfe-commits] r49535 - /cfe/trunk/lib/Lex/Lexer.cpp
Neil Booth
neil at daikokuya.co.uk
Fri Apr 11 18:39:49 PDT 2008
Chris Lattner wrote:-
> Author: lattner
> Date: Fri Apr 11 11:20:41 2008
> New Revision: 49535
>
> URL: http://llvm.org/viewvc/llvm-project?rev=49535&view=rev
> Log:
> don't read off the front of the buffer. Thanks to Sam for pointing this out.
>
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=49535&r1=49534&r2=49535&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Fri Apr 11 11:20:41 2008
> @@ -1142,7 +1142,7 @@
> }
>
> // 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);
I don't think this is right Chris. This will warn about an empty
file; the standard explicitly gives empty files a free pass. The
following text is the reason for the existence of this diagnostic
(5.1.1.2p2):
A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character
before any such splicing takes place.
Perhaps CurPtr != BufferStart && is what you want?
Neil.
More information about the cfe-commits
mailing list