diff options
author | Neil Booth <neilb@earthling.net> | 2000-12-03 12:06:23 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-12-03 12:06:23 +0000 |
commit | 8aaef6e0c9109dd291029f543042900660fae287 (patch) | |
tree | 859e06921d833c83e0f3252c95f0749efd56bcff /gcc/cppmacro.c | |
parent | 94a3d3b9c3b3dbc41385eab24645a76e76db3cb2 (diff) | |
download | gcc-8aaef6e0c9109dd291029f543042900660fae287.zip gcc-8aaef6e0c9109dd291029f543042900660fae287.tar.gz gcc-8aaef6e0c9109dd291029f543042900660fae287.tar.bz2 |
cppmacro.c (funlike_invocation_p): Re-disable macros enabled by contexts drops AFTER argument pre-expansion...
* cppmacro.c (funlike_invocation_p): Re-disable macros enabled
by contexts drops AFTER argument pre-expansion, so that they
remain enabled during argument pre-expansion.
(_cpp_pop_context): Unconditionally re-enable a macro when
dropping a context level.
From-SVN: r37971
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index eed2798..0afb9d0 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -606,7 +606,7 @@ funlike_invocation_p (pfile, node, list) const cpp_hashnode *node; struct toklist *list; { - cpp_context *orig_context; + cpp_context *orig, *final; cpp_token maybe_paren; macro_arg *args = 0; cpp_lexer_pos macro_pos; @@ -614,7 +614,7 @@ funlike_invocation_p (pfile, node, list) macro_pos = pfile->lexer_pos; pfile->state.parsing_args = 1; pfile->state.prevent_expansion++; - orig_context = pfile->context; + orig = pfile->context; cpp_start_lookahead (pfile); cpp_get_token (pfile, &maybe_paren); @@ -628,7 +628,8 @@ funlike_invocation_p (pfile, node, list) node->name); /* Restore original context. */ - pfile->context = orig_context; + final = pfile->context; + pfile->context = orig; pfile->state.prevent_expansion--; pfile->state.parsing_args = 0; @@ -648,6 +649,13 @@ funlike_invocation_p (pfile, node, list) free (args); } + /* Re-disable macros *after* pre-expansion. */ + while (final != orig) + { + final = final->next; + final->macro->disabled = 1; + } + return args != 0; } @@ -885,13 +893,12 @@ _cpp_pop_context (pfile) cpp_context *context = pfile->context; pfile->context = context->prev; - /* Re-enable a macro and free resources when leaving its expansion. */ - if (!pfile->state.parsing_args) - { - if (!pfile->context->prev) - unlock_pools (pfile); - context->macro->disabled = 0; - } + if (!pfile->context->prev && !pfile->state.parsing_args) + unlock_pools (pfile); + + /* Re-enable a macro, temporarily if parsing_args, when leaving its + expansion. */ + context->macro->disabled = 0; } /* Eternal routine to get a token. Also used nearly everywhere |