aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppmacro.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-01-28 11:22:23 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-01-28 11:22:23 +0000
commit26ec42ee4d266cf25be73a29888abf906b2d10ef (patch)
tree1d89d6c0190e47c079ba3aba7080beb23ee2e05a /gcc/cppmacro.c
parent6001735ea0da3d5d89a8f249a79fc8198ff28513 (diff)
downloadgcc-26ec42ee4d266cf25be73a29888abf906b2d10ef.zip
gcc-26ec42ee4d266cf25be73a29888abf906b2d10ef.tar.gz
gcc-26ec42ee4d266cf25be73a29888abf906b2d10ef.tar.bz2
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
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r--gcc/cppmacro.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index a7d71a0..aea7e5d 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -146,7 +146,6 @@ builtin_macro (pfile, token)
cpp_reader *pfile;
cpp_token *token;
{
- unsigned char flags = token->flags & PREV_WHITE;
cpp_hashnode *node = token->val.node;
switch (node->value.builtin)
@@ -220,8 +219,6 @@ builtin_macro (pfile, token)
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
@@ -671,13 +668,13 @@ enter_macro_context (pfile, node)
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;
}
@@ -712,6 +709,7 @@ replace_args (pfile, macro, args, list)
macro_arg *args;
struct toklist *list;
{
+ unsigned char flags = 0;
unsigned int i, total;
const cpp_token *src, *limit;
cpp_token *dest;
@@ -804,11 +802,20 @@ replace_args (pfile, macro, args, list)
/* 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;
@@ -913,8 +920,6 @@ cpp_get_token (pfile, token)
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);
@@ -923,6 +928,8 @@ cpp_get_token (pfile, token)
{
if (context->macro)
{
+ /* Avoid accidental paste at the end of a macro. */
+ flags |= AVOID_LPASTE;
_cpp_pop_context (pfile);
continue;
}
@@ -932,6 +939,8 @@ cpp_get_token (pfile, token)
return;
}
+ token->flags |= flags;
+ flags = 0;
if (token->type != CPP_NAME)
break;
@@ -945,15 +954,16 @@ cpp_get_token (pfile, token)
/* 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))