From 99c32175dedefd515b7f39129f979817349a80f3 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 12 May 2001 16:02:01 +0000 Subject: [PATCH] * cpplex.c (_cpp_lex_token): Ensure we warn at most once about files not ending in newlines. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41995 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/cpplex.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 745094d..1839c19 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-05-12 Neil Booth + + * cpplex.c (_cpp_lex_token): Ensure we warn at most once + about files not ending in newlines. + 2001-05-12 Alexandre Oliva * config/arm/arm.h (TARGET_PTRMEMFUNC_VBIT_LOCATION): Use delta. diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 9bbab0f..f25913f 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -890,9 +890,11 @@ _cpp_lex_token (pfile, result) switch (c) { case EOF: - /* Non-empty files should end in a newline. Ignore for command - line and _Pragma buffers. */ - if (pfile->lexer_pos.col != 0 && !buffer->from_stage3) + /* Non-empty files should end in a newline. Checking "bol" too + prevents multiple warnings when hitting the EOF more than + once, like in a directive. Don't warn for command line and + _Pragma buffers. */ + if (pfile->lexer_pos.col != 0 && !bol && !buffer->from_stage3) cpp_pedwarn (pfile, "no newline at end of file"); pfile->state.next_bol = 1; pfile->skipping = 0; /* In case missing #endif. */ -- 2.7.4