From: Neil Booth Date: Sun, 28 Jan 2001 11:22:23 +0000 (+0000) Subject: cpphash.c (_cpp_cleanup_hashtable, [...]): Don't set fe_value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=26ec42ee4d266cf25be73a29888abf906b2d10ef;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecbe8331252..90f2f068517 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2001-01-28 Neil Booth + + * 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 * config/alpha/t-ieee: Remove multilibbing. diff --git a/gcc/cpphash.c b/gcc/cpphash.c index 4804c8fec50..d4c9e376dd9 100644 --- a/gcc/cpphash.c +++ b/gcc/cpphash.c @@ -73,10 +73,7 @@ _cpp_cleanup_hashtable (pfile) do { if (*p) - { - _cpp_free_definition (*p); - (*p)->fe_value = 0; /* expose the node to GC */ - } + _cpp_free_definition (*p); } while (++p < limit); @@ -169,7 +166,6 @@ _cpp_lookup_with_hash (pfile, len, hash) 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; diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 1dc401e8f08..f9431f812fd 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1656,7 +1656,7 @@ cpp_avoid_paste (pfile, token1, token2) 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)) diff --git a/gcc/cpplib.h b/gcc/cpplib.h index c109a0f8ca6..9d0b8e253fb 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -166,6 +166,7 @@ struct cpp_string #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. */ @@ -487,8 +488,6 @@ struct cpp_hashnode 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. */ diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index a7d71a09644..aea7e5dab6d 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)) diff --git a/gcc/cppmain.c b/gcc/cppmain.c index ecc27e42d6b..13bbbdd3c4f 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -235,8 +235,8 @@ scan_buffer (pfile) } } 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;