* 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
+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>
* diagnostic.c: Fix typos in comments.
static void print_help PARAMS ((void));
static void path_include PARAMS ((cpp_reader *,
char *, int));
+static void initialize PARAMS ((void));
static void initialize_builtins PARAMS ((cpp_reader *));
static void append_include_chain PARAMS ((cpp_reader *,
char *, int, int));
cppchar_t c;
cpp_buffer *buffer;
const unsigned char *comment_start;
- unsigned char bol = pfile->state.next_bol;
+ unsigned char bol;
+ skip:
+ bol = pfile->state.next_bol;
done_directive:
buffer = pfile->buffer;
pfile->state.next_bol = 0;
handle_newline (buffer, c);
bol = 1;
pfile->lexer_pos.output_line = buffer->lineno;
-
- /* Newlines in arguments are white space (6.10.3.10).
- Otherwise, clear any white space flag. */
- if (pfile->state.parsing_args)
- result->flags |= PREV_WHITE;
- else
- result->flags &= ~PREV_WHITE;
+ /* This is a new line, so clear any white space flag.
+ Newlines in arguments are white space (6.10.3.10);
+ parse_arg takes care of that. */
+ result->flags &= ~PREV_WHITE;
goto next_char;
}
break;
}
+ if (pfile->skipping)
+ goto skip;
+
/* If not in a directive, this token invalidates controlling macros. */
if (!pfile->state.in_directive)
pfile->mi_state = MI_FAILED;
{
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 #. */
if (skip_line)
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. */
pfile->la_write = pfile->la_saved;
pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
/* Lexer state. */
struct lexer_state state;
- /* The position of the last lexed token, last lexed directive, and
- last macro invocation. */
+ /* The position of the last lexed token and last lexed directive. */
cpp_lexer_pos lexer_pos;
- cpp_lexer_pos macro_pos;
cpp_lexer_pos directive_pos;
/* Memory pools. */
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;
}
{
enum cpp_ttype result;
unsigned int paren = 0;
+ unsigned int line;
arg->first = (cpp_token *) POOL_FRONT (&pfile->argument_pool);
for (;; 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);
- 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)
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;
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. */
/* 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))
{
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
return;
}
- /* Loop until we're not skipping. */
- if (pfile->skipping)
- continue;
-
if (token->type != CPP_NAME)
break;