diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-08-21 06:20:18 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-08-21 06:20:18 +0000 |
commit | d7bc7a9850ac55871f1108c491585118e10afd04 (patch) | |
tree | d3294a0e95ec060c7d36c19a66723166c94ce0f9 /gcc/cpplex.c | |
parent | bb1a503c19ca810ff94db1674cbe607f903d1ffc (diff) | |
download | gcc-d7bc7a9850ac55871f1108c491585118e10afd04.zip gcc-d7bc7a9850ac55871f1108c491585118e10afd04.tar.gz gcc-d7bc7a9850ac55871f1108c491585118e10afd04.tar.bz2 |
cpphash.h (_cpp_push_next_buffer): New.
* 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.
From-SVN: r45070
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 e1657a7..a24acab 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; } |