Commit 26ec42ee by Neil Booth Committed by Neil Booth

cpphash.c (_cpp_cleanup_hashtable, [...]): Don't set fe_value.

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

From-SVN: r39318
parent 6001735e
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> 2001-01-27 Richard Henderson <rth@redhat.com>
* config/alpha/t-ieee: Remove multilibbing. * config/alpha/t-ieee: Remove multilibbing.
......
...@@ -73,10 +73,7 @@ _cpp_cleanup_hashtable (pfile) ...@@ -73,10 +73,7 @@ _cpp_cleanup_hashtable (pfile)
do do
{ {
if (*p) if (*p)
{
_cpp_free_definition (*p); _cpp_free_definition (*p);
(*p)->fe_value = 0; /* expose the node to GC */
}
} }
while (++p < limit); while (++p < limit);
...@@ -169,7 +166,6 @@ _cpp_lookup_with_hash (pfile, len, hash) ...@@ -169,7 +166,6 @@ _cpp_lookup_with_hash (pfile, len, hash)
entry = entries[index]; entry = entries[index];
entry->type = NT_VOID; entry->type = NT_VOID;
entry->flags = 0; entry->flags = 0;
entry->fe_value = 0;
entry->directive_index = 0; entry->directive_index = 0;
entry->arg_index = 0; entry->arg_index = 0;
entry->length = len; entry->length = len;
......
...@@ -1656,7 +1656,7 @@ cpp_avoid_paste (pfile, token1, token2) ...@@ -1656,7 +1656,7 @@ cpp_avoid_paste (pfile, token1, token2)
case CPP_OR: return c == '|'; case CPP_OR: return c == '|';
case CPP_COLON: return c == ':' || c == '>'; case CPP_COLON: return c == ':' || c == '>';
case CPP_DEREF: return 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_HASH: return c == '#' || c == '%'; /* Digraph form. */
case CPP_NAME: return ((b == CPP_NUMBER case CPP_NAME: return ((b == CPP_NUMBER
&& name_p (pfile, &token2->val.str)) && name_p (pfile, &token2->val.str))
......
...@@ -166,6 +166,7 @@ struct cpp_string ...@@ -166,6 +166,7 @@ struct cpp_string
#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */ #define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
#define NAMED_OP (1 << 4) /* C++ named operators. */ #define NAMED_OP (1 << 4) /* C++ named operators. */
#define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */ #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 /* A preprocessing token. This has been carefully packed and should
occupy 12 bytes on 32-bit hosts and 16 bytes on 64-bit hosts. */ occupy 12 bytes on 32-bit hosts and 16 bytes on 64-bit hosts. */
...@@ -487,8 +488,6 @@ struct cpp_hashnode ...@@ -487,8 +488,6 @@ struct cpp_hashnode
enum cpp_ttype operator; /* Code for a named operator. */ enum cpp_ttype operator; /* Code for a named operator. */
enum builtin_type builtin; /* Code for a builtin macro. */ enum builtin_type builtin; /* Code for a builtin macro. */
} value; } value;
union tree_node *fe_value; /* Front end value. */
}; };
/* Call this first to get a handle to pass to other functions. */ /* Call this first to get a handle to pass to other functions. */
......
...@@ -146,7 +146,6 @@ builtin_macro (pfile, token) ...@@ -146,7 +146,6 @@ builtin_macro (pfile, token)
cpp_reader *pfile; cpp_reader *pfile;
cpp_token *token; cpp_token *token;
{ {
unsigned char flags = token->flags & PREV_WHITE;
cpp_hashnode *node = token->val.node; cpp_hashnode *node = token->val.node;
switch (node->value.builtin) switch (node->value.builtin)
...@@ -220,8 +219,6 @@ builtin_macro (pfile, token) ...@@ -220,8 +219,6 @@ builtin_macro (pfile, token)
cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name); cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name);
break; break;
} }
token->flags = flags;
} }
/* Used by cpperror.c to obtain the correct line and column to report /* Used by cpperror.c to obtain the correct line and column to report
...@@ -671,9 +668,9 @@ enter_macro_context (pfile, node) ...@@ -671,9 +668,9 @@ enter_macro_context (pfile, node)
list.limit = macro->expansion + macro->count; list.limit = macro->expansion + macro->count;
} }
/* Only push a macro context for non-empty replacement lists. */
if (list.first != list.limit) if (list.first != list.limit)
{ {
/* Push its context. */
context = next_context (pfile); context = next_context (pfile);
context->list = list; context->list = list;
context->macro = macro; context->macro = macro;
...@@ -712,6 +709,7 @@ replace_args (pfile, macro, args, list) ...@@ -712,6 +709,7 @@ replace_args (pfile, macro, args, list)
macro_arg *args; macro_arg *args;
struct toklist *list; struct toklist *list;
{ {
unsigned char flags = 0;
unsigned int i, total; unsigned int i, total;
const cpp_token *src, *limit; const cpp_token *src, *limit;
cpp_token *dest; cpp_token *dest;
...@@ -804,11 +802,20 @@ replace_args (pfile, macro, args, list) ...@@ -804,11 +802,20 @@ replace_args (pfile, macro, args, list)
/* The last token gets the PASTE_LEFT of the CPP_MACRO_ARG. */ /* The last token gets the PASTE_LEFT of the CPP_MACRO_ARG. */
dest[count - 1].flags |= src->flags & PASTE_LEFT; dest[count - 1].flags |= src->flags & PASTE_LEFT;
dest[0].flags |= AVOID_LPASTE;
dest += count; dest += count;
} }
/* The token after the argument must avoid an accidental paste. */
flags = AVOID_LPASTE;
} }
else else
*dest++ = *src; {
*dest = *src;
dest->flags |= flags;
dest++;
flags = 0;
}
list->limit = dest; list->limit = dest;
...@@ -913,8 +920,6 @@ cpp_get_token (pfile, token) ...@@ -913,8 +920,6 @@ cpp_get_token (pfile, token)
else if (context->list.first != context->list.limit) else if (context->list.first != context->list.limit)
{ {
*token = *context->list.first++; *token = *context->list.first++;
token->flags |= flags;
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) if (token->flags & PASTE_LEFT)
paste_all_tokens (pfile, token); paste_all_tokens (pfile, token);
...@@ -923,6 +928,8 @@ cpp_get_token (pfile, token) ...@@ -923,6 +928,8 @@ cpp_get_token (pfile, token)
{ {
if (context->macro) if (context->macro)
{ {
/* Avoid accidental paste at the end of a macro. */
flags |= AVOID_LPASTE;
_cpp_pop_context (pfile); _cpp_pop_context (pfile);
continue; continue;
} }
...@@ -932,6 +939,8 @@ cpp_get_token (pfile, token) ...@@ -932,6 +939,8 @@ cpp_get_token (pfile, token)
return; return;
} }
token->flags |= flags;
flags = 0;
if (token->type != CPP_NAME) if (token->type != CPP_NAME)
break; break;
...@@ -945,15 +954,16 @@ cpp_get_token (pfile, token) ...@@ -945,15 +954,16 @@ cpp_get_token (pfile, token)
/* Macros invalidate controlling macros. */ /* Macros invalidate controlling macros. */
pfile->mi_state = MI_FAILED; 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) if (node->flags & NODE_BUILTIN)
{ {
builtin_macro (pfile, token); builtin_macro (pfile, token);
token->flags = flags;
break; break;
} }
/* Merge PREV_WHITE of tokens. */
flags = token->flags & PREV_WHITE;
if (node->value.macro->disabled) if (node->value.macro->disabled)
token->flags |= NO_EXPAND; token->flags |= NO_EXPAND;
else if (enter_macro_context (pfile, node)) else if (enter_macro_context (pfile, node))
......
...@@ -235,8 +235,8 @@ scan_buffer (pfile) ...@@ -235,8 +235,8 @@ scan_buffer (pfile)
} }
} }
else if (print.printed else if (print.printed
&& ! (token->flags & PREV_WHITE) && (token->flags & (PREV_WHITE | AVOID_LPASTE))
&& options->lang != CLK_ASM == AVOID_LPASTE
&& cpp_avoid_paste (pfile, &tokens[1 - index], token)) && cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE; token->flags |= PREV_WHITE;
......
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