diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-08-20 16:32:29 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-08-20 16:32:29 +0000 |
commit | a570d97f5b8612ad2756333e5f21098be64057df (patch) | |
tree | 8ef03edd4d66a34af550bf97a6a1ea02e32c7bc6 /libcpp/directives.c | |
parent | 7692e253ee0bdab40fb896991f9208112ebfff61 (diff) | |
download | gcc-a570d97f5b8612ad2756333e5f21098be64057df.zip gcc-a570d97f5b8612ad2756333e5f21098be64057df.tar.gz gcc-a570d97f5b8612ad2756333e5f21098be64057df.tar.bz2 |
[CPP PATCH] node type
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01164.html
* include/cpplib.h (NODE_BUILTIN, NODE_MACRO_ARG): Delete.
Renumber others.
(enum node_type): Replace NT_MACRO with NT_USER_MACRO,
NT_BUILTIN_MACRO, NT_MACRO_ARG. Delete NT_ASSERTION.
(NTV_MACRO, NTV_ANSWER, NTV_BUILTIN, NTV_ARGUMENT, NTV_NONE):
Delete.
(CPP_HASHNODE_VALUE_IDX): Delete.
(union _cpp_hashnode_value): GTY tag from enum node_type directly.
(struct cpp_hashnode): Adjust GTY desc for value field.
(cpp_user_macro_p, cpp_builtin_macro_p, cpp_macro_p): Adjust.
* directives.c (undefine_macros): Clear value.anwers, adjust flag
clearing.
(_cpp_test_assertion): No need to check NT_ASSERTION.
(do_assert, do_unassert): Likewise.
* init.c (cpp_init_special_builtins): Set type not flags.
* macro.c (struct macro_arg_saved_data): Add type field.
(cpp_get_token_1): Check type not NT_VOID.
(_cpp_free_definition): Adjust flag clearing. Nullify
value.answers.
(_cpp_save_parameter, _cpp_unsave_parameters): Save and restore
type.
(lex_expansion_token): Check type not flags.
(_cpp_create_definition): Set type to NT_USER_MACRO.
(_cpp_notify_macro_use): Adjust type checking.
* pch.c (write_macdef, count_defs, write_defs, cpp_valid_state)
(save_macros): Adjust node type/flag handling.
* traditional.c (_cpp_scan_out_logical_line): Check type not flags.
From-SVN: r263667
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r-- | libcpp/directives.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c index f04ed7c..f7c460d 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -695,7 +695,8 @@ undefine_macros (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *h, /* Body of _cpp_free_definition inlined here for speed. Macros and assertions no longer have anything to free. */ h->type = NT_VOID; - h->flags &= ~(NODE_POISONED|NODE_BUILTIN|NODE_DISABLED|NODE_USED); + h->value.answers = NULL; + h->flags &= ~(NODE_POISONED|NODE_DISABLED|NODE_USED); return 1; } @@ -2217,9 +2218,10 @@ parse_answer (cpp_reader *pfile, int type, source_location pred_loc, } /* Parses an assertion directive of type TYPE, returning a pointer to - the hash node of the predicate, or 0 on error. If an answer was - supplied, it is placed in EXP_PTR & EXP_COUNT, which is otherwise - set to 0. */ + the hash node of the predicate, or 0 on error. The node is + guaranteed to be disjoint from the macro namespace, so can only + have type 'NT_VOID'. If an answer was supplied, it is placed in + *ANSWER_PTR, which is otherwise set to 0. */ static cpp_hashnode * parse_assertion (cpp_reader *pfile, int type, cpp_macro **answer_ptr) { @@ -2294,7 +2296,7 @@ _cpp_test_assertion (cpp_reader *pfile, unsigned int *value) if (node) { - if (node->type == NT_ASSERTION) + if (node->value.answers) *value = !answer || *find_answer (node, answer); } else if (pfile->cur_token[-1].type == CPP_EOF) @@ -2315,7 +2317,7 @@ do_assert (cpp_reader *pfile) { /* Place the new answer in the answer list. First check there is not a duplicate. */ - if (node->type == NT_ASSERTION && *find_answer (node, answer)) + if (*find_answer (node, answer)) { cpp_error (pfile, CPP_DL_WARNING, "\"%s\" re-asserted", NODE_NAME (node) + 1); @@ -2327,10 +2329,8 @@ do_assert (cpp_reader *pfile) (pfile, sizeof (cpp_macro) - sizeof (cpp_token) + sizeof (cpp_token) * answer->count); - if (node->type == NT_ASSERTION) - answer->parm.next = node->value.answers; - - node->type = NT_ASSERTION; + /* Chain into the list. */ + answer->parm.next = node->value.answers; node->value.answers = answer; check_eol (pfile, false); @@ -2345,7 +2345,7 @@ do_unassert (cpp_reader *pfile) cpp_hashnode *node = parse_assertion (pfile, T_UNASSERT, &answer); /* It isn't an error to #unassert something that isn't asserted. */ - if (node && node->type == NT_ASSERTION) + if (node) { if (answer) { @@ -2353,12 +2353,7 @@ do_unassert (cpp_reader *pfile) /* Remove the assert from the list. */ if (cpp_macro *temp = *p) - { - *p = temp->parm.next; - /* Did we free the last answer? */ - if (!*p) - node->type = NT_VOID; - } + *p = temp->parm.next; check_eol (pfile, false); } |