+2001-01-28 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cpphash.c (_cpp_cleanup_hashtable, _cpp_lookup_with_hash)
+ : Don't set fe_value.
+ * cpplib.h (AVOID_LPASTE): New flag.
+ (struct cpp_hashnode): Remove fe_value.
+ * cpplex.c (cpp_avoid_paste): Don't paste '.' with a number.
+ * cppmacro.c (builtin_macro): Don't set flags here.
+ (replace_args): Set AVOID_LPASTE flag on first token of an
+ argument, and the token following it.
+ (cpp_get_token): Set AVOID_LPASTE flag on first token of a
+ macro expansion, and on the token following it. Do it for
+ builtins too.
+ * cppmain.c (scan_buffer): Avoid pasting only flagged tokens.
+
2001-01-27 Richard Henderson <rth@redhat.com>
* config/alpha/t-ieee: Remove multilibbing.
do
{
if (*p)
- {
- _cpp_free_definition (*p);
- (*p)->fe_value = 0; /* expose the node to GC */
- }
+ _cpp_free_definition (*p);
}
while (++p < limit);
entry = entries[index];
entry->type = NT_VOID;
entry->flags = 0;
- entry->fe_value = 0;
entry->directive_index = 0;
entry->arg_index = 0;
entry->length = len;
case CPP_OR: return c == '|';
case CPP_COLON: return c == ':' || c == '>';
case CPP_DEREF: return c == '*';
- case CPP_DOT: return c == '.' || c == '%';
+ case CPP_DOT: return c == '.' || c == '%' || b == CPP_NUMBER;
case CPP_HASH: return c == '#' || c == '%'; /* Digraph form. */
case CPP_NAME: return ((b == CPP_NUMBER
&& name_p (pfile, &token2->val.str))
#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
#define NAMED_OP (1 << 4) /* C++ named operators. */
#define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */
+#define AVOID_LPASTE (1 << 6) /* Check left for accidental pastes. */
/* A preprocessing token. This has been carefully packed and should
occupy 12 bytes on 32-bit hosts and 16 bytes on 64-bit hosts. */
enum cpp_ttype operator; /* Code for a named operator. */
enum builtin_type builtin; /* Code for a builtin macro. */
} value;
-
- union tree_node *fe_value; /* Front end value. */
};
/* Call this first to get a handle to pass to other functions. */
cpp_reader *pfile;
cpp_token *token;
{
- unsigned char flags = token->flags & PREV_WHITE;
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
list.limit = macro->expansion + macro->count;
}
+ /* Only push a macro context for non-empty replacement lists. */
if (list.first != list.limit)
{
- /* Push its context. */
context = next_context (pfile);
context->list = list;
context->macro = macro;
-
+
/* Disable the macro within its expansion. */
macro->disabled = 1;
}
macro_arg *args;
struct toklist *list;
{
+ unsigned char flags = 0;
unsigned int i, total;
const cpp_token *src, *limit;
cpp_token *dest;
/* 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;
}
+
+ /* The token after the argument must avoid an accidental paste. */
+ flags = AVOID_LPASTE;
}
else
- *dest++ = *src;
+ {
+ *dest = *src;
+ dest->flags |= flags;
+ dest++;
+ flags = 0;
+ }
list->limit = dest;
else if (context->list.first != context->list.limit)
{
*token = *context->list.first++;
- token->flags |= flags;
- flags = 0;
/* PASTE_LEFT tokens can only appear in macro expansions. */
if (token->flags & PASTE_LEFT)
paste_all_tokens (pfile, token);
{
if (context->macro)
{
+ /* Avoid accidental paste at the end of a macro. */
+ 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;
}
- /* Merge PREV_WHITE of tokens. */
- flags = token->flags & PREV_WHITE;
-
if (node->value.macro->disabled)
token->flags |= NO_EXPAND;
else if (enter_macro_context (pfile, node))
}
}
else if (print.printed
- && ! (token->flags & PREV_WHITE)
- && options->lang != CLK_ASM
+ && (token->flags & (PREV_WHITE | AVOID_LPASTE))
+ == AVOID_LPASTE
&& cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE;