diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-21 06:20:18 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-21 06:20:18 +0000 |
commit | fe56063735d5ada48f5157d27ba21c2e1e9496f3 (patch) | |
tree | d3294a0e95ec060c7d36c19a66723166c94ce0f9 /gcc/cpplex.c | |
parent | 42938542aa5068c3fcabd6cfcebc823a05490be5 (diff) | |
download | gcc-fe56063735d5ada48f5157d27ba21c2e1e9496f3.tar.gz |
* cpphash.h (_cpp_push_next_buffer): New.
* cppinit.c (do_includes): Remove.
(push_include, free_chain, _cpp_push_next_buffer): New.
(cpp_start_read): Use them to rework command line option handling.
(cpp_handle_option): Combine handling of -include and -imacros.
* cpplex.c (_cpp_lex_token): Push a new -include buffer if
appropriate. Always insert missing \n at EOF.
* cpplib.c (start_directive): Get the directive position right.
* cppmain.c (cb_file_change): Always print the first line, unless
preprocessed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45070 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index e1657a783ce..a24acabd578 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -890,6 +890,17 @@ _cpp_lex_token (pfile, result) switch (c) { case 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, prevent multiple warnings. */ + pfile->line++; + pfile->lexer_pos.col = 0; + if (!buffer->from_stage3) + cpp_pedwarn (pfile, "no newline at end of file"); + } + /* To prevent bogus diagnostics, only pop the buffer when in-progress directives and arguments have been taken care of. Decrement the line to terminate an in-progress directive. */ @@ -897,23 +908,15 @@ _cpp_lex_token (pfile, result) pfile->lexer_pos.output_line = pfile->line--; else if (! pfile->state.parsing_args) { - /* 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, prevent multiple warnings. */ - pfile->line++; - pfile->lexer_pos.col = 0; - if (!buffer->from_stage3) - cpp_pedwarn (pfile, "no newline at end of file"); - } - - /* Don't pop the last file. */ + /* Don't pop the last buffer. */ if (buffer->prev) { unsigned char stop = buffer->return_at_eof; _cpp_pop_buffer (pfile); + /* Push the next -included file, if any. */ + if (!pfile->buffer->prev) + _cpp_push_next_buffer (pfile); if (!stop) goto next_token; } |