diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-01 22:01:10 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-01 22:01:10 +0000 |
commit | 8b7d9415bd76c370448a77322aa23137b0b8e380 (patch) | |
tree | b2d9610f10a0aa663383569503ef2c3432eb0dd8 /gcc/cppmacro.c | |
parent | f95934b8aff5e77deff566acb087e4e9143d5ed9 (diff) | |
download | gcc-8b7d9415bd76c370448a77322aa23137b0b8e380.tar.gz |
* cppinit.c (initialize): Forgotten prototype.
* cpplex.c (_cpp_lex_token): Loop until not skipping.
Always clear PREV_WHITE upon meeting a new line.
* cpplib.c (end_directive): Set pfile->skipping after
skip_rest_of_line.
* cpplib.h (cpp_reader): Remove macro_pos.
* cppmacro.c (cpp_get_line): Don't do anything special inside
macros.
(parse_arg): Add PREV_WHITE if a token appears after new lines.
(funlike_invocation_p): Save and restore the output position
over a successful check for a '('.
(enter_macro_context): Delete uses of macro_pos.
(cpp_get_token): Don't use pfile->skipping.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37927 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 637e5e95536..eed2798fc7b 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -236,10 +236,6 @@ const cpp_lexer_pos * cpp_get_line (pfile) cpp_reader *pfile; { - /* Within a macro expansion, return the position of the outermost - invocation. */ - if (pfile->context->prev) - return &pfile->macro_pos; return &pfile->lexer_pos; } @@ -489,6 +485,7 @@ parse_arg (pfile, arg, var_args) { enum cpp_ttype result; unsigned int paren = 0; + unsigned int line; arg->first = (cpp_token *) POOL_FRONT (&pfile->argument_pool); for (;; arg->count++) @@ -501,9 +498,13 @@ parse_arg (pfile, arg, var_args) token = &arg->first[arg->count]; } + /* Newlines in arguments are white space (6.10.3.10). */ + line = pfile->lexer_pos.output_line; cpp_get_token (pfile, token); - result = token->type; + if (line != pfile->lexer_pos.output_line) + token->flags |= PREV_WHITE; + result = token->type; if (result == CPP_OPEN_PAREN) paren++; else if (result == CPP_CLOSE_PAREN && paren-- == 0) @@ -608,7 +609,9 @@ funlike_invocation_p (pfile, node, list) cpp_context *orig_context; cpp_token maybe_paren; macro_arg *args = 0; + cpp_lexer_pos macro_pos; + macro_pos = pfile->lexer_pos; pfile->state.parsing_args = 1; pfile->state.prevent_expansion++; orig_context = pfile->context; @@ -631,6 +634,9 @@ funlike_invocation_p (pfile, node, list) if (args) { + /* The macro's expansion appears where the name would have. */ + pfile->lexer_pos = macro_pos; + if (node->value.macro->paramc > 0) { /* Don't save tokens during pre-expansion. */ @@ -660,10 +666,7 @@ enter_macro_context (pfile, node) /* Save the position of the outermost macro invocation. */ if (!pfile->context->prev) - { - pfile->macro_pos = pfile->lexer_pos; - lock_pools (pfile); - } + lock_pools (pfile); if (macro->fun_like && !funlike_invocation_p (pfile, node, &list)) { @@ -924,7 +927,7 @@ cpp_get_token (pfile, token) token->flags |= flags; flags = 0; /* PASTE_LEFT tokens can only appear in macro expansions. */ - if (token->flags & PASTE_LEFT && !pfile->skipping) + if (token->flags & PASTE_LEFT) paste_all_tokens (pfile, token); } else @@ -940,10 +943,6 @@ cpp_get_token (pfile, token) return; } - /* Loop until we're not skipping. */ - if (pfile->skipping) - continue; - if (token->type != CPP_NAME) break; |