From 7364fdd8e0b52133f3cd8e49d72f465ae6128118 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Tue, 7 Aug 2001 20:37:26 +0000 Subject: cppinit.c (cpp_finish): Pop the final buffer without comment. * cppinit.c (cpp_finish): Pop the final buffer without comment. * cpplex.c (_cpp_lex_token): Don't pop the final buffer; and take care to avoid multiple no-newline at EOF warnings in that case. From-SVN: r44701 --- gcc/cpplex.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'gcc/cpplex.c') diff --git a/gcc/cpplex.c b/gcc/cpplex.c index f9c4bb9..5e0aa5a 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -897,21 +897,26 @@ _cpp_lex_token (pfile, result) pfile->line--; else if (! pfile->state.parsing_args) { - unsigned char ret = pfile->buffer->return_at_eof; - /* Non-empty files should end in a newline. Don't warn for command line and _Pragma buffers. */ if (pfile->lexer_pos.col != 0) { - /* Account for the missing \n. */ + /* Account for the missing \n, prevent multiple warnings. */ pfile->line++; + pfile->lexer_pos.col = 0; if (!buffer->from_stage3) cpp_pedwarn (pfile, "no newline at end of file"); } - _cpp_pop_buffer (pfile); - if (pfile->buffer && !ret) - goto next_token; + /* Don't pop the last file. */ + if (buffer->prev) + { + unsigned char stop = buffer->return_at_eof; + + _cpp_pop_buffer (pfile); + if (!stop) + goto next_token; + } } result->type = CPP_EOF; return; -- cgit v1.1