aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2002-04-22 17:48:02 +0000
committerNeil Booth <neil@gcc.gnu.org>2002-04-22 17:48:02 +0000
commitaf0d16cdec59d270a017f82ac209c44dfa748ea3 (patch)
tree0fc130b06a7d9e6cdc2502aaa5f671bb726c8773 /gcc/cpplib.c
parent74b273d68f6a479fa9a563ff87ef3e9561408c2c (diff)
downloadgcc-af0d16cdec59d270a017f82ac209c44dfa748ea3.zip
gcc-af0d16cdec59d270a017f82ac209c44dfa748ea3.tar.gz
gcc-af0d16cdec59d270a017f82ac209c44dfa748ea3.tar.bz2
cppfiles.c (_cpp_pop_file_buffer): Return void.
* cppfiles.c (_cpp_pop_file_buffer): Return void. Move file change and include code to _cpp_pop_buffer. * cpphash.h (struct pending_option): Predeclare. (struct cpp_reader): New member next_include_file. (_cpp_pop_file_buffer): Update. (_cpp_push_next_buffer): Update, rename. * cppinit.c (cpp_destroy): Free include chain and pending here. (cpp_finish_options): Simplify. (_cpp_push_next_buffer): Rename and clean up. * cpplib.c (cpp_pop_buffer): Move code from _cpp_pop_file_buffer. Clarify. * cppmacro.c (cpp_scan_nooutput): Set return_at_eof here. From-SVN: r52621
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index dddf86a..712b9df 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -1900,16 +1900,15 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
return new;
}
-/* If called from do_line, pops a single buffer. Otherwise pops all
- buffers until a real file is reached. Generates appropriate
- call-backs. */
+/* Pops a single buffer, with a file change call-back if appropriate.
+ Then pushes the next -include file, if any remain. */
void
_cpp_pop_buffer (pfile)
cpp_reader *pfile;
{
cpp_buffer *buffer = pfile->buffer;
+ struct include_file *inc = buffer->inc;
struct if_stack *ifs;
- bool pushed = false;
/* Walk back up the conditional stack till we reach its level at
entry to this file, issuing error messages. */
@@ -1920,14 +1919,28 @@ _cpp_pop_buffer (pfile)
/* In case of a missing #endif. */
pfile->state.skipping = 0;
- /* Update the reader's buffer before _cpp_do_file_change. */
+ /* _cpp_do_file_change expects pfile->buffer to be the new one. */
pfile->buffer = buffer->prev;
- if (buffer->inc)
- pushed = _cpp_pop_file_buffer (pfile, buffer->inc);
+ /* Free the buffer object now; we may want to push a new buffer
+ in _cpp_push_next_include_file. */
+ obstack_free (&pfile->buffer_ob, buffer);
- if (!pushed)
- obstack_free (&pfile->buffer_ob, buffer);
+ if (inc)
+ {
+ _cpp_pop_file_buffer (pfile, inc);
+
+ /* Don't generate a callback for popping the main file. */
+ if (pfile->buffer)
+ {
+ _cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
+
+ /* If this is the main file, there may be some -include
+ files left to push. */
+ if (!pfile->buffer->prev)
+ _cpp_maybe_push_include_file (pfile);
+ }
+ }
}
/* Enter all recognised directives in the hash table. */