+2001-02-01 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cpphash.h (struct cpp_buffer): Move saved_flags from cpp_reader.
+ * cpplex.c (_cpp_lex_token): New token picks up the saved flags,
+ and AVOID_LPASTE is cleared on meeting an unescaped newline.
+ * cppmacro.c (builtin_macro): Set builtin flags here.
+ (paste_all_tokens): Preserve AVOID_LPASTE on pasted token.
+ (replace_args): Clarify intent.
+ (cpp_get_token): Macro expansion tokens get the saved flags.
+ Update.
+ * cppmain.c (scan_buffer): Remove now-redundant print.printed
+ check.
+
2001-02-01 Jeffrey Oldham <oldham@codesourcery.com>
* config/mips/iris6.h (SUPPORTS_INIT_PRIORITY): Reverse change of
/* Line number at line_base (above). */
unsigned int lineno;
+ /* Contains PREV_WHITE and/or AVOID_LPASTE. */
+ unsigned char saved_flags;
+
/* Because of the way the lexer works, -Wtrigraphs can sometimes
warn twice for the same trigraph. This helps prevent that. */
const unsigned char *last_Wtrigraphs;
/* We're printed a warning recommending against using #import. */
unsigned char import_warning;
- /* Used to flag the token after a paste AVOID_LPASTE. */
- unsigned char saved_flags;
-
/* True after cpp_start_read completes. Used to inhibit some
warnings while parsing the command line. */
unsigned char done_initializing;
done_directive:
buffer = pfile->buffer;
pfile->state.next_bol = 0;
- result->flags = 0;
+ result->flags = buffer->saved_flags;
+ buffer->saved_flags = 0;
next_char:
pfile->lexer_pos.line = buffer->lineno;
next_char2:
/* 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;
+ result->flags &= ~(PREV_WHITE | AVOID_LPASTE);
goto next_char;
}
/* Get whitespace right - newline_in_args sets it. */
if (pfile->lexer_pos.col == 1)
- result->flags &= ~PREV_WHITE;
+ result->flags &= ~(PREV_WHITE | AVOID_LPASTE);
}
else
{
cpp_reader *pfile;
cpp_token *token;
{
+ unsigned char flags = ((token->flags & PREV_WHITE) | AVOID_LPASTE);
cpp_hashnode *node = token->val.node;
switch (node->value.builtin)
cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name);
break;
}
+
+ token->flags = flags;
}
/* Used by cpperror.c to obtain the correct line and column to report
/* The pasted token has the PREV_WHITE flag of the LHS, is no longer
PASTE_LEFT, and is subject to macro expansion. */
lhs->flags &= ~(PREV_WHITE | PASTE_LEFT | NO_EXPAND);
- lhs->flags |= orig_flags & PREV_WHITE;
+ lhs->flags |= orig_flags & (PREV_WHITE | AVOID_LPASTE);
}
/* Reads the unexpanded tokens of a macro argument into ARG. VAR_ARGS
/* The first token gets PREV_WHITE of the CPP_MACRO_ARG. */
dest->flags &= ~PREV_WHITE;
dest->flags |= src->flags & PREV_WHITE;
+ dest->flags |= AVOID_LPASTE;
/* The last token gets the PASTE_LEFT of the CPP_MACRO_ARG. */
dest[count - 1].flags |= src->flags & PASTE_LEFT;
- dest[0].flags |= AVOID_LPASTE;
dest += count;
}
cpp_reader *pfile;
cpp_token *token;
{
- unsigned char flags = pfile->saved_flags;
-
- pfile->saved_flags = 0;
-
for (;;)
{
cpp_context *context = pfile->context;
else if (context->list.first != context->list.limit)
{
*token = *context->list.first++;
+ token->flags |= pfile->buffer->saved_flags;
+ pfile->buffer->saved_flags = 0;
/* PASTE_LEFT tokens can only appear in macro expansions. */
if (token->flags & PASTE_LEFT)
{
paste_all_tokens (pfile, token);
- pfile->saved_flags = AVOID_LPASTE;
+ pfile->buffer->saved_flags = AVOID_LPASTE;
}
}
else
if (context->macro)
{
/* Avoid accidental paste at the end of a macro. */
- flags |= AVOID_LPASTE;
+ pfile->buffer->saved_flags |= AVOID_LPASTE;
_cpp_pop_context (pfile);
continue;
}
return;
}
- token->flags |= flags;
- flags = 0;
if (token->type != CPP_NAME)
break;
/* Macros invalidate controlling macros. */
pfile->mi_state = MI_FAILED;
- /* Remember PREV_WHITE and avoid an accidental paste. */
- flags = (token->flags & PREV_WHITE) | AVOID_LPASTE;
-
if (node->flags & NODE_BUILTIN)
{
builtin_macro (pfile, token);
- token->flags = flags;
break;
}
if (node->value.macro->disabled)
token->flags |= NO_EXPAND;
else if (enter_macro_context (pfile, node))
- continue;
+ {
+ /* Pass AVOID_LPASTE and our PREV_WHITE to next token. */
+ pfile->buffer->saved_flags = ((token->flags & PREV_WHITE)
+ | AVOID_LPASTE);
+ continue;
+ }
}
/* Don't interpret _Pragma within directives. The standard is