[PATCH] #assert becomes macro-like

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01140.html
	libcpp/
	* include/cpp-id-data.h (struct answer): Delete.
	* include/cpplib.h (struct answer): Don't forward-declare.
	(enum cpp_macro_kind): Add cmk_assert.
	(struct cpp_macro): Union parms and next assert chain.
	(union _cpp_hashnode_value): 'answer' field is cpp_macro.
	* directives.c (parse_answer): Convert to use cpp_macro. Return
	true on success. 
	(parse_assertion, find_answer, _cpp_test_assertion, cpp_do_assert)
	(cpp_do_unassert): Convert to use cpp_macro.
	* macro.c (warn_of_redefinition, _cpp_new_macro)
	(check_trad_stringification, cpp_macro_definition): Adjust macro
	parm access.
	* traditional.c (_cpp_replacement_text_len)
	(_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise.
	gcc/c-family/
	* c-ada-spec.c (macro_length, dump_ada_macros): Adjust macro parm
	access.

From-SVN: r263658
This commit is contained in:
Nathan Sidwell 2018-08-20 12:39:36 +00:00 committed by Nathan Sidwell
parent b655b8fc7e
commit 3fb558b154
8 changed files with 129 additions and 125 deletions

View file

@ -3017,7 +3017,7 @@ warn_of_redefinition (cpp_reader *pfile, cpp_hashnode *node,
/* Check parameter spellings. */
for (i = 0; i < macro1->paramc; i++)
if (macro1->params[i] != macro2->params[i])
if (macro1->parm.params[i] != macro2->parm.params[i])
return true;
/* Check the replacement text or tokens. */
@ -3326,7 +3326,7 @@ create_iso_definition (cpp_reader *pfile)
{
macro->variadic = varadic;
macro->paramc = nparms;
macro->params = params;
macro->parm.params = params;
macro->fun_like = true;
}
else
@ -3472,7 +3472,7 @@ _cpp_new_macro (cpp_reader *pfile, cpp_macro_kind kind, void *placement)
cpp_macro *macro = (cpp_macro *) placement;
macro->line = pfile->directive_line;
macro->params = 0;
macro->parm.params = 0;
macro->lazy = 0;
macro->paramc = 0;
macro->variadic = 0;
@ -3618,7 +3618,7 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro,
identifier inside the string matches one of them. */
for (i = 0; i < macro->paramc; i++)
{
const cpp_hashnode *node = macro->params[i];
const cpp_hashnode *node = macro->parm.params[i];
if (NODE_LEN (node) == len
&& !memcmp (p, NODE_NAME (node), len))
@ -3663,7 +3663,7 @@ cpp_macro_definition (cpp_reader *pfile, cpp_hashnode *node)
len += 4; /* "()" plus possible final ".." of named
varargs (we have + 1 below). */
for (i = 0; i < macro->paramc; i++)
len += NODE_LEN (macro->params[i]) + 1; /* "," */
len += NODE_LEN (macro->parm.params[i]) + 1; /* "," */
}
/* This should match below where we fill in the buffer. */
@ -3707,7 +3707,7 @@ cpp_macro_definition (cpp_reader *pfile, cpp_hashnode *node)
*buffer++ = '(';
for (i = 0; i < macro->paramc; i++)
{
cpp_hashnode *param = macro->params[i];
cpp_hashnode *param = macro->parm.params[i];
if (param != pfile->spec_nodes.n__VA_ARGS__)
{