Commit 8d9e9a08 by Neil Booth Committed by Neil Booth

cppinit.c (initialize): Forgotten prototype.

        * 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.

From-SVN: r37927
parent a717799c
2000-12-01 Neil Booth <neilb@earthling.net>
* 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.
2000-12-01 Phil Edwards <pme@sources.redhat.com> 2000-12-01 Phil Edwards <pme@sources.redhat.com>
* diagnostic.c: Fix typos in comments. * diagnostic.c: Fix typos in comments.
......
...@@ -94,6 +94,7 @@ struct cpp_pending ...@@ -94,6 +94,7 @@ struct cpp_pending
static void print_help PARAMS ((void)); static void print_help PARAMS ((void));
static void path_include PARAMS ((cpp_reader *, static void path_include PARAMS ((cpp_reader *,
char *, int)); char *, int));
static void initialize PARAMS ((void));
static void initialize_builtins PARAMS ((cpp_reader *)); static void initialize_builtins PARAMS ((cpp_reader *));
static void append_include_chain PARAMS ((cpp_reader *, static void append_include_chain PARAMS ((cpp_reader *,
char *, int, int)); char *, int, int));
......
...@@ -850,8 +850,10 @@ _cpp_lex_token (pfile, result) ...@@ -850,8 +850,10 @@ _cpp_lex_token (pfile, result)
cppchar_t c; cppchar_t c;
cpp_buffer *buffer; cpp_buffer *buffer;
const unsigned char *comment_start; const unsigned char *comment_start;
unsigned char bol = pfile->state.next_bol; unsigned char bol;
skip:
bol = pfile->state.next_bol;
done_directive: done_directive:
buffer = pfile->buffer; buffer = pfile->buffer;
pfile->state.next_bol = 0; pfile->state.next_bol = 0;
...@@ -894,12 +896,9 @@ _cpp_lex_token (pfile, result) ...@@ -894,12 +896,9 @@ _cpp_lex_token (pfile, result)
handle_newline (buffer, c); handle_newline (buffer, c);
bol = 1; bol = 1;
pfile->lexer_pos.output_line = buffer->lineno; pfile->lexer_pos.output_line = buffer->lineno;
/* This is a new line, so clear any white space flag.
/* Newlines in arguments are white space (6.10.3.10). Newlines in arguments are white space (6.10.3.10);
Otherwise, clear any white space flag. */ parse_arg takes care of that. */
if (pfile->state.parsing_args)
result->flags |= PREV_WHITE;
else
result->flags &= ~PREV_WHITE; result->flags &= ~PREV_WHITE;
goto next_char; goto next_char;
} }
...@@ -1276,6 +1275,9 @@ _cpp_lex_token (pfile, result) ...@@ -1276,6 +1275,9 @@ _cpp_lex_token (pfile, result)
break; break;
} }
if (pfile->skipping)
goto skip;
/* If not in a directive, this token invalidates controlling macros. */ /* If not in a directive, this token invalidates controlling macros. */
if (!pfile->state.in_directive) if (!pfile->state.in_directive)
pfile->mi_state = MI_FAILED; pfile->mi_state = MI_FAILED;
......
...@@ -247,14 +247,14 @@ end_directive (pfile, skip_line) ...@@ -247,14 +247,14 @@ end_directive (pfile, skip_line)
{ {
cpp_buffer *buffer = pfile->buffer; cpp_buffer *buffer = pfile->buffer;
/* Restore pfile->skipping before skip_rest_of_line. This avoids
warning about poisoned identifiers in skipped #error lines. */
pfile->skipping = buffer->was_skipping;
/* We don't skip for an assembler #. */ /* We don't skip for an assembler #. */
if (skip_line) if (skip_line)
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
/* Restore pfile->skipping after skip_rest_of_line. Otherwise the
lexer might not return! */
pfile->skipping = buffer->was_skipping;
/* Restore state. */ /* Restore state. */
pfile->la_write = pfile->la_saved; pfile->la_write = pfile->la_saved;
pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments); pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
......
...@@ -498,10 +498,8 @@ struct cpp_reader ...@@ -498,10 +498,8 @@ struct cpp_reader
/* Lexer state. */ /* Lexer state. */
struct lexer_state state; struct lexer_state state;
/* The position of the last lexed token, last lexed directive, and /* The position of the last lexed token and last lexed directive. */
last macro invocation. */
cpp_lexer_pos lexer_pos; cpp_lexer_pos lexer_pos;
cpp_lexer_pos macro_pos;
cpp_lexer_pos directive_pos; cpp_lexer_pos directive_pos;
/* Memory pools. */ /* Memory pools. */
......
...@@ -236,10 +236,6 @@ const cpp_lexer_pos * ...@@ -236,10 +236,6 @@ const cpp_lexer_pos *
cpp_get_line (pfile) cpp_get_line (pfile)
cpp_reader *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; return &pfile->lexer_pos;
} }
...@@ -489,6 +485,7 @@ parse_arg (pfile, arg, var_args) ...@@ -489,6 +485,7 @@ parse_arg (pfile, arg, var_args)
{ {
enum cpp_ttype result; enum cpp_ttype result;
unsigned int paren = 0; unsigned int paren = 0;
unsigned int line;
arg->first = (cpp_token *) POOL_FRONT (&pfile->argument_pool); arg->first = (cpp_token *) POOL_FRONT (&pfile->argument_pool);
for (;; arg->count++) for (;; arg->count++)
...@@ -501,9 +498,13 @@ parse_arg (pfile, arg, var_args) ...@@ -501,9 +498,13 @@ parse_arg (pfile, arg, var_args)
token = &arg->first[arg->count]; 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); 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) if (result == CPP_OPEN_PAREN)
paren++; paren++;
else if (result == CPP_CLOSE_PAREN && paren-- == 0) else if (result == CPP_CLOSE_PAREN && paren-- == 0)
...@@ -608,7 +609,9 @@ funlike_invocation_p (pfile, node, list) ...@@ -608,7 +609,9 @@ funlike_invocation_p (pfile, node, list)
cpp_context *orig_context; cpp_context *orig_context;
cpp_token maybe_paren; cpp_token maybe_paren;
macro_arg *args = 0; macro_arg *args = 0;
cpp_lexer_pos macro_pos;
macro_pos = pfile->lexer_pos;
pfile->state.parsing_args = 1; pfile->state.parsing_args = 1;
pfile->state.prevent_expansion++; pfile->state.prevent_expansion++;
orig_context = pfile->context; orig_context = pfile->context;
...@@ -631,6 +634,9 @@ funlike_invocation_p (pfile, node, list) ...@@ -631,6 +634,9 @@ funlike_invocation_p (pfile, node, list)
if (args) if (args)
{ {
/* The macro's expansion appears where the name would have. */
pfile->lexer_pos = macro_pos;
if (node->value.macro->paramc > 0) if (node->value.macro->paramc > 0)
{ {
/* Don't save tokens during pre-expansion. */ /* Don't save tokens during pre-expansion. */
...@@ -660,10 +666,7 @@ enter_macro_context (pfile, node) ...@@ -660,10 +666,7 @@ enter_macro_context (pfile, node)
/* Save the position of the outermost macro invocation. */ /* Save the position of the outermost macro invocation. */
if (!pfile->context->prev) 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)) if (macro->fun_like && !funlike_invocation_p (pfile, node, &list))
{ {
...@@ -924,7 +927,7 @@ cpp_get_token (pfile, token) ...@@ -924,7 +927,7 @@ cpp_get_token (pfile, token)
token->flags |= flags; token->flags |= flags;
flags = 0; flags = 0;
/* PASTE_LEFT tokens can only appear in macro expansions. */ /* 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); paste_all_tokens (pfile, token);
} }
else else
...@@ -940,10 +943,6 @@ cpp_get_token (pfile, token) ...@@ -940,10 +943,6 @@ cpp_get_token (pfile, token)
return; return;
} }
/* Loop until we're not skipping. */
if (pfile->skipping)
continue;
if (token->type != CPP_NAME) if (token->type != CPP_NAME)
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment