diff options
author | Neil Booth <neilb@earthling.net> | 2000-11-12 11:46:21 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-11-12 11:46:21 +0000 |
commit | b528a07e0e5693ec33b7e77c600c0b32117f7742 (patch) | |
tree | f74638e6668fd7907064468bc11254a90aefe287 /gcc/cppmacro.c | |
parent | 46bdc296a8c34fb42a934e21878817970541560e (diff) | |
download | gcc-b528a07e0e5693ec33b7e77c600c0b32117f7742.zip gcc-b528a07e0e5693ec33b7e77c600c0b32117f7742.tar.gz gcc-b528a07e0e5693ec33b7e77c600c0b32117f7742.tar.bz2 |
cppexp.c: Don't worry about pfile->skipping.
* cppexp.c: Don't worry about pfile->skipping.
* cpplib.c (struct if_stack): Make was_skipping unsigned char.
(cpp_handle_directive): Save pfile->skipping in struct cpp_buffer
for handled directives.
(skip_rest_of_line): Use _cpp_lex_token after popping contexts
and releasing lookaheads.
(do_ifdef, do_ifndef, do_if): Use buffer->was_skipping.
(do_else, do_elif, push_conditional): Update logic.
(do_endif): Set buffer->was_skipping rather than pfile->skipping.
(unwind_if_stack): Inline into cpp_pop_buffer.
(cpp_push_buffer): Clear ifs->was_skipping for cpp_handle_directive.
* cpplex.c (_cpp_lex_token): Clear skipping on EOF. Handle
multiple-include optimisation.
* cpplib.h (struct cpp_buffer): New member was_skipping.
* cppmacro.c (_cpp_get_token): Loop whilst pfile->skipping. This
works because skipping == 0 in directives.
(_cpp_release_lookahead): Renamed from release_lookahead.
(cpp_get_token): No need to check skipping as _cpp_get_token does
this for us. No need to handle MI optimisation.
From-SVN: r37404
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 43a9010..7ea70850 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -86,7 +86,6 @@ static void replace_args PARAMS ((cpp_reader *, cpp_macro *, macro_arg *, static void save_lookahead_token PARAMS ((cpp_reader *, const cpp_token *)); static void take_lookahead_token PARAMS ((cpp_reader *, cpp_token *)); -static void release_lookahead PARAMS ((cpp_reader *)); static cpp_lookahead *alloc_lookahead PARAMS ((cpp_reader *)); static void free_lookahead PARAMS ((cpp_lookahead *)); @@ -897,7 +896,7 @@ _cpp_get_token (pfile, token) cpp_token *token; { next_token: - for (;;) + do { cpp_context *context = pfile->context; @@ -913,22 +912,15 @@ _cpp_get_token (pfile, token) if (context->macro) { _cpp_pop_context (pfile); - continue; + goto next_token; } /* End of argument pre-expansion. */ token->type = CPP_EOF; token->flags = 0; + return; } - break; } - - /* Only perform macro expansion (and therefore pasting) when not - skipping, or when skipping but in a directive. The only - directive where this could be true is #elif. A possible later - optimisation: get do_elif to clear skipping so we don't need the - directive test here. */ - if (pfile->skipping && !pfile->state.in_directive) - return; + while (pfile->skipping); for (;;) { @@ -985,21 +977,7 @@ cpp_get_token (pfile, token) cpp_reader *pfile; cpp_token *token; { - for (;;) - { - _cpp_get_token (pfile, token); - - if (token->type == CPP_EOF) - break; - else if (pfile->skipping) - continue; - - /* Non-comment tokens invalidate any controlling macros. */ - if (token->type != CPP_COMMENT) - pfile->mi_state = MI_FAILED; - - break; - } + _cpp_get_token (pfile, token); if (pfile->la_write) save_lookahead_token (pfile, token); @@ -1057,12 +1035,12 @@ take_lookahead_token (pfile, token) pfile->lexer_pos = twp->pos; if (++la->cur == la->count) - release_lookahead (pfile); + _cpp_release_lookahead (pfile); } /* Moves the lookahead at the front of the read list to the free store. */ -static void -release_lookahead (pfile) +void +_cpp_release_lookahead (pfile) cpp_reader *pfile; { cpp_lookahead *la = pfile->la_read; @@ -1151,7 +1129,7 @@ cpp_stop_lookahead (pfile, drop) pfile->la_read = la; if (drop || la->count == 0) - release_lookahead (pfile); + _cpp_release_lookahead (pfile); else pfile->lexer_pos = la->pos; } |