aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorNeil Booth <neil@cat.daikokuya.demon.co.uk>2001-08-04 12:01:59 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-08-04 12:01:59 +0000
commitef6e958a8611ff372211d0fd3cd9659614583bb4 (patch)
tree0aaaf48e2153d5621bc68cb09f9c0d2ef9a3854a /gcc/cpplex.c
parent03997728b499f76a20356705aa4d05d808ab9c3c (diff)
downloadgcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.zip
gcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.tar.gz
gcc-ef6e958a8611ff372211d0fd3cd9659614583bb4.tar.bz2
Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h are also on line-map.h.
* Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h are also on line-map.h. * cppfiles.c (stack_include_file): Update. * cpphash.h (struct cpp_buffer): New member return_at_eof. (_cpp_pop_buffer): New. * cppinit.c (cpp_destroy, cpp_finish): Update. (do_includes): Mark each buffer to return at EOF. * cpplex.c (_cpp_lex_token): Pop buffers at EOF. Continue or return as requested. * cpplib.c (run_directive, do_line, cpp_push_buffer): Update. (cpp_pop_buffer): Rename _cpp_pop_buffer. Stop skipping. * cpplib.h (cpp_pop_buffer): Remove. (cpp_scan_buffer_nooutput): Rename cpp_scan_nooutput. * cppmacro.c (cpp_scan_buffer_nooutput): Similarly. No need to pop buffers. * cppmain.c (scan_buffer): Rename scan_translation_unit. No need to pop buffers. (do_preprocessing): Update. * fix-header.c (read_scan_file): Update. No need to pop buffers. * c-parse.in (_yylex): Similarly. * scan-decls.c (scan_decls): Similarly. * line-map.h: Update comments. * cp/spew.c (read_token): No need to pop buffers. * objc/Make-lang.in (objc-act.o): Update dependencies. From-SVN: r44634
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index fa32bd5..e0002be 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -893,16 +893,23 @@ _cpp_lex_token (pfile, result)
switch (c)
{
case EOF:
- /* 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");
+ if (!pfile->state.in_directive)
+ {
+ 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 && !buffer->from_stage3)
+ cpp_pedwarn (pfile, "no newline at end of file");
+ _cpp_pop_buffer (pfile);
+ if (pfile->buffer && !ret)
+ {
+ bol = 1;
+ goto done_directive;
+ }
+ }
pfile->state.next_bol = 1;
- pfile->state.skipping = 0; /* In case missing #endif. */
result->type = CPP_EOF;
- /* Don't do MI optimisation. */
return;
case ' ': case '\t': case '\f': case '\v': case '\0':