* cppexp.c (lex): Use NODE_NAME and NODE_LEN.
* cpphash.c (_cpp_lookup_with_hash): Similarly.
* cpplex.c (cpp_ideq, parse_identifier, cpp_token_len,
cpp_spell_token, cpp_output_token): Similarly.
* cpplib.c (lex_macro_node, do_undef, do_pragma,
do_pragma_poison, parse_assertion, do_assert): Similarly.
* cppmacro.c (builtin_macro, parse_args, funlike_invocation_p,
save_parameter, _cpp_create_definition, check_trad_stringification,
cpp_macro_definition): Similarly.
* cppmain.c (cb_define, cb_undef, dump_macro): Similarly.
* c-lex.c (cb_undef, c_lex): Similarly.
* fix-header.c (recognized_function): Similarly.
* cpplib.h (NODE_LEN, NODE_NAME): New.
(cpp_hashnode): Rename length len.
From-SVN: r42174
+2001-05-16 Neil Booth <neil@cat.daikokuya.demon.co.uk>
+
+ * cppexp.c (lex): Use NODE_NAME and NODE_LEN.
+ * cpphash.c (_cpp_lookup_with_hash): Similarly.
+ * cpplex.c (cpp_ideq, parse_identifier, cpp_token_len,
+ cpp_spell_token, cpp_output_token): Similarly.
+ * cpplib.c (lex_macro_node, do_undef, do_pragma,
+ do_pragma_poison, parse_assertion, do_assert): Similarly.
+ * cppmacro.c (builtin_macro, parse_args, funlike_invocation_p,
+ save_parameter, _cpp_create_definition, check_trad_stringification,
+ cpp_macro_definition): Similarly.
+ * cppmain.c (cb_define, cb_undef, dump_macro): Similarly.
+ * c-lex.c (cb_undef, c_lex): Similarly.
+ * fix-header.c (recognized_function): Similarly.
+ * cpplib.h (NODE_LEN, NODE_NAME): New.
+ (cpp_hashnode): Rename length len.
+
Wed May 16 13:41:10 2001 Jeffrey A Law (law@cygnus.com)
* pa32-regs.h (HARD_REGNO_MODE_OK): Allow TI/TFmode values in
cpp_reader *pfile ATTRIBUTE_UNUSED;
cpp_hashnode *node;
{
- debug_undef (lineno, (const char *) node->name);
+ debug_undef (lineno, (const char *) NODE_NAME (node));
}
/* Parse a '\uNNNN' or '\UNNNNNNNN' sequence.
goto retry;
case CPP_NAME:
- *value = get_identifier ((const char *)tok.val.node->name);
+ *value = get_identifier ((const char *) NODE_NAME (tok.val.node));
break;
case CPP_INT:
if (CPP_PEDANTIC (pfile)
&& ! cpp_defined (pfile, DSC("__bool_true_false_are_defined")))
cpp_pedwarn (pfile, "ISO C++ does not permit \"%s\" in #if",
- token->val.node->name);
+ NODE_NAME (token->val.node));
return op;
}
else
op.value = 0;
if (CPP_OPTION (pfile, warn_undef) && !skip_evaluation)
- cpp_warning (pfile, "\"%s\" is not defined", token->val.node->name);
+ cpp_warning (pfile, "\"%s\" is not defined",
+ NODE_NAME (token->val.node));
return op;
}
{
unsigned int hash2;
- if (entry->hash == hash && entry->length == len
- && !memcmp (entry->name, name, len))
+ if (entry->hash == hash && NODE_LEN (entry) == len
+ && !memcmp (NODE_NAME (entry), name, len))
return entry;
hash2 = 1 + hash % (size - 2);
if (entry == NULL)
break;
- if (entry->hash == hash && entry->length == len
- && !memcmp (entry->name, name, len))
+ if (entry->hash == hash && NODE_LEN (entry) == len
+ && !memcmp (NODE_NAME (entry), name, len))
return entry;
}
}
entry->flags = 0;
entry->directive_index = 0;
entry->arg_index = 0;
- entry->length = len;
+ NODE_LEN (entry) = len;
entry->hash = hash;
- entry->name = name;
+ NODE_NAME (entry) = name;
entry->value.macro = 0;
pfile->hashtab->nelts++;
if (token->type != CPP_NAME)
return 0;
- return !ustrcmp (token->val.node->name, (const U_CHAR *) string);
+ return !ustrcmp (NODE_NAME (token->val.node), (const U_CHAR *) string);
}
/* Call when meeting a newline. Returns the character after the newline
{
/* It is allowed to poison the same identifier twice. */
if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok)
- cpp_error (pfile, "attempt to use poisoned \"%s\"", result->name);
+ cpp_error (pfile, "attempt to use poisoned \"%s\"",
+ NODE_NAME (result));
/* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the
replacement list of a variadic macro. */
switch (TOKEN_SPELL (token))
{
- default: len = 0; break;
- case SPELL_STRING: len = token->val.str.len; break;
- case SPELL_IDENT: len = token->val.node->length; break;
+ default: len = 0; break;
+ case SPELL_STRING: len = token->val.str.len; break;
+ case SPELL_IDENT: len = NODE_LEN (token->val.node); break;
}
/* 1 for whitespace, 4 for comment delimeters. */
return len + 5;
case SPELL_IDENT:
spell_ident:
- memcpy (buffer, token->val.node->name, token->val.node->length);
- buffer += token->val.node->length;
+ memcpy (buffer, NODE_NAME (token->val.node), NODE_LEN (token->val.node));
+ buffer += NODE_LEN (token->val.node);
break;
case SPELL_STRING:
spell_ident:
case SPELL_IDENT:
- ufputs (token->val.node->name, fp);
+ ufputs (NODE_NAME (token->val.node), fp);
break;
case SPELL_STRING:
else if (token.flags & NAMED_OP)
cpp_error (pfile,
"\"%s\" cannot be used as a macro name as it is an operator in C++",
- token.val.node->name);
+ NODE_NAME (token.val.node));
else
cpp_error (pfile, "macro names must be identifiers");
}
/* In Objective C, some keywords begin with '@', but general
identifiers do not, and you're not allowed to #define them. */
- if (node == pfile->spec_nodes.n_defined || node->name[0] == '@')
- cpp_error (pfile, "\"%s\" cannot be used as a macro name", node->name);
+ if (node == pfile->spec_nodes.n_defined || NODE_NAME (node)[0] == '@')
+ cpp_error (pfile, "\"%s\" cannot be used as a macro name",
+ NODE_NAME (node));
else if (!(node->flags & NODE_POISONED))
return node;
}
(*pfile->cb.undef) (pfile, node);
if (node->flags & NODE_WARN)
- cpp_warning (pfile, "undefining \"%s\"", node->name);
+ cpp_warning (pfile, "undefining \"%s\"", NODE_NAME (node));
_cpp_free_definition (node);
}
{
const struct pragma_entry *p;
cpp_token tok;
- const cpp_hashnode *node;
- const U_CHAR *name;
- size_t len;
int drop = 0;
p = pfile->pragmas;
cpp_get_token (pfile, &tok);
if (tok.type == CPP_NAME)
{
- node = tok.val.node;
- name = node->name;
- len = node->length;
+ const cpp_hashnode *node = tok.val.node;
+ const U_CHAR *name = NODE_NAME (node);
+ size_t len = NODE_LEN (node);
+
while (p)
{
if (strlen (p->name) == len && !memcmp (p->name, name, len))
continue;
if (hp->type == NT_MACRO)
- cpp_warning (pfile, "poisoning existing macro \"%s\"", hp->name);
+ cpp_warning (pfile, "poisoning existing macro \"%s\"", NODE_NAME (hp));
_cpp_free_definition (hp);
hp->flags |= NODE_POISONED | NODE_DIAGNOSTIC;
}
cpp_error (pfile, "predicate must be an identifier");
else if (parse_answer (pfile, answerp, type) == 0)
{
- unsigned int len = predicate.val.node->length;
+ unsigned int len = NODE_LEN (predicate.val.node);
unsigned char *sym = alloca (len + 1);
/* Prefix '#' to get it out of macro namespace. */
sym[0] = '#';
- memcpy (sym + 1, predicate.val.node->name, len);
+ memcpy (sym + 1, NODE_NAME (predicate.val.node), len);
result = cpp_lookup (pfile, sym, len + 1);
}
{
if (*find_answer (node, new_answer))
{
- cpp_warning (pfile, "\"%s\" re-asserted", node->name + 1);
+ cpp_warning (pfile, "\"%s\" re-asserted", NODE_NAME (node) + 1);
return;
}
new_answer->next = node->value.answers;
BT_STDC /* `__STDC__' */
};
-/* There is a slot in the hashnode for use by front ends when integrated
- with cpplib. It holds a tree (see tree.h) but we mustn't drag that
- header into every user of cpplib.h. cpplib does not do anything with
- this slot except clear it when a new node is created. */
-union tree_node;
+#define NODE_LEN(NODE) (NODE->len)
+#define NODE_NAME(NODE) (NODE->name)
struct cpp_hashnode
{
const unsigned char *name; /* Null-terminated name. */
unsigned int hash; /* Cached hash value. */
- unsigned short length; /* Length of name excluding null. */
+ unsigned short len; /* Length of name excluding null. */
unsigned short arg_index; /* Macro argument index. */
unsigned char directive_index; /* Index into directive table. */
ENUM_BITFIELD(node_type) type : 8; /* Node type. */
break;
default:
- cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name);
+ cpp_ice (pfile, "invalid builtin macro \"%s\"", NODE_NAME (node));
break;
}
if (type == CPP_EOF)
{
cpp_error (pfile, "unterminated argument list invoking macro \"%s\"",
- node->name);
+ NODE_NAME (node));
error = 1;
}
else if (argc < macro->paramc)
{
cpp_error (pfile,
"macro \"%s\" requires %u arguments, but only %u given",
- node->name, macro->paramc, argc);
+ NODE_NAME (node), macro->paramc, argc);
error = 1;
}
}
{
cpp_error (pfile,
"macro \"%s\" passed %u arguments, but takes just %u",
- node->name, argc, macro->paramc);
+ NODE_NAME (node), argc, macro->paramc);
error = 1;
}
}
else if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
cpp_warning (pfile,
"function-like macro \"%s\" must be used with arguments in traditional C",
- node->name);
+ NODE_NAME (node));
/* Restore original context. */
pfile->context = orig;
/* Constraint 6.10.3.6 - duplicate parameter names. */
if (node->arg_index)
{
- cpp_error (pfile, "duplicate macro parameter \"%s\"", node->name);
+ cpp_error (pfile, "duplicate macro parameter \"%s\"", NODE_NAME (node));
return 1;
}
{
cpp_pedwarn_with_line (pfile, pfile->directive_pos.line,
pfile->directive_pos.col,
- "\"%s\" redefined", node->name);
+ "\"%s\" redefined", NODE_NAME (node));
if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
cpp_pedwarn_with_file_and_line (pfile,
/* Enter definition in hash table. */
node->type = NT_MACRO;
node->value.macro = macro;
- if (! ustrncmp (node->name, DSC ("__STDC_")))
+ if (! ustrncmp (NODE_NAME (node), DSC ("__STDC_")))
node->flags |= NODE_WARN;
cleanup:
{
const cpp_hashnode *node = macro->params[i];
- if (node->length == len && !memcmp (p, node->name, len))
+ if (NODE_LEN (node) == len && !memcmp (p, NODE_NAME (node), len))
{
cpp_warning (pfile,
"macro argument \"%s\" would be stringified with -traditional.",
- node->name);
+ NODE_NAME (node));
break;
}
}
{
len += 3; /* "()" plus possible final "." of ellipsis. */
for (i = 0; i < macro->paramc; i++)
- len += macro->params[i]->length + 2; /* ", " */
+ len += NODE_LEN (macro->params[i]) + 2; /* ", " */
}
for (i = 0; i < macro->count; i++)
cpp_token *token = ¯o->expansion[i];
if (token->type == CPP_MACRO_ARG)
- len += macro->params[token->val.arg_no - 1]->length;
+ len += NODE_LEN (macro->params[token->val.arg_no - 1]);
else
len += cpp_token_len (token); /* Includes room for ' '. */
if (token->flags & STRINGIFY_ARG)
if (param != pfile->spec_nodes.n__VA_ARGS__)
{
- memcpy (buffer, param->name, param->length);
- buffer += param->length;
+ memcpy (buffer, NODE_NAME (param), NODE_LEN (param));
+ buffer += NODE_LEN (param);
}
if (i + 1 < macro->paramc)
if (token->type == CPP_MACRO_ARG)
{
- len = macro->params[token->val.arg_no - 1]->length;
- memcpy (buffer, macro->params[token->val.arg_no - 1]->name, len);
+ len = NODE_LEN (macro->params[token->val.arg_no - 1]);
+ memcpy (buffer,
+ NODE_NAME (macro->params[token->val.arg_no - 1]), len);
buffer += len;
}
else
cpp_hashnode *node;
{
maybe_print_line (cpp_get_line (pfile)->output_line);
- fprintf (print.outf, "#define %s", node->name);
+ fprintf (print.outf, "#define %s", NODE_NAME (node));
/* -dD command line option. */
if (options->dump_macros == dump_definitions)
cpp_hashnode *node;
{
maybe_print_line (cpp_get_line (pfile)->output_line);
- fprintf (print.outf, "#undef %s\n", node->name);
+ fprintf (print.outf, "#undef %s\n", NODE_NAME (node));
print.lineno++;
}
{
if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
{
- fprintf (print.outf, "#define %s", node->name);
+ fprintf (print.outf, "#define %s", NODE_NAME (node));
fputs ((const char *) cpp_macro_definition (pfile, node), print.outf);
putc ('\n', print.outf);
print.lineno++;
missing_extern_C_count++;
#endif
- fn = lookup_std_proto ((const char *)fname->val.node->name,
- fname->val.node->length);
+ fn = lookup_std_proto ((const char *) NODE_NAME (fname->val.node),
+ NODE_LEN (fname->val.node));
/* Remove the function from the list of required function. */
if (fn)