aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c53
1 files changed, 9 insertions, 44 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 352c591..6ddfce6 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1666,7 +1666,7 @@ do_pragma_poison (cpp_reader *pfile)
if (hp->flags & NODE_POISONED)
continue;
- if (hp->type == NT_MACRO)
+ if (cpp_macro_p (hp))
cpp_error (pfile, CPP_DL_WARNING, "poisoning existing macro \"%s\"",
NODE_NAME (hp));
_cpp_free_definition (hp);
@@ -1960,26 +1960,9 @@ do_ifdef (cpp_reader *pfile)
the powerpc and spu ports using conditional macros for 'vector',
'bool', and 'pixel' to act as conditional keywords. This messes
up tests like #ifndef bool. */
- skip = (node->type != NT_MACRO
- || ((node->flags & NODE_CONDITIONAL) != 0));
+ skip = !cpp_macro_p (node) || (node->flags & NODE_CONDITIONAL);
_cpp_mark_macro_used (node);
- if (!(node->flags & NODE_USED))
- {
- node->flags |= NODE_USED;
- if (node->type == NT_MACRO)
- {
- if ((node->flags & NODE_BUILTIN)
- && pfile->cb.user_builtin_macro)
- pfile->cb.user_builtin_macro (pfile, node);
- if (pfile->cb.used_define)
- pfile->cb.used_define (pfile, pfile->directive_line, node);
- }
- else
- {
- if (pfile->cb.used_undef)
- pfile->cb.used_undef (pfile, pfile->directive_line, node);
- }
- }
+ _cpp_maybe_notify_macro_use (pfile, node);
if (pfile->cb.used)
pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
@@ -2006,26 +1989,10 @@ do_ifndef (cpp_reader *pfile)
the powerpc and spu ports using conditional macros for 'vector',
'bool', and 'pixel' to act as conditional keywords. This messes
up tests like #ifndef bool. */
- skip = (node->type == NT_MACRO
- && ((node->flags & NODE_CONDITIONAL) == 0));
+ skip = (cpp_macro_p (node)
+ && !(node->flags & NODE_CONDITIONAL));
_cpp_mark_macro_used (node);
- if (!(node->flags & NODE_USED))
- {
- node->flags |= NODE_USED;
- if (node->type == NT_MACRO)
- {
- if ((node->flags & NODE_BUILTIN)
- && pfile->cb.user_builtin_macro)
- pfile->cb.user_builtin_macro (pfile, node);
- if (pfile->cb.used_define)
- pfile->cb.used_define (pfile, pfile->directive_line, node);
- }
- else
- {
- if (pfile->cb.used_undef)
- pfile->cb.used_undef (pfile, pfile->directive_line, node);
- }
- }
+ _cpp_maybe_notify_macro_use (pfile, node);
if (pfile->cb.used)
pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
@@ -2508,18 +2475,18 @@ cpp_pop_definition (cpp_reader *pfile, struct def_pragma_macro *c)
if (pfile->cb.before_define)
pfile->cb.before_define (pfile);
- if (node->type == NT_MACRO)
+ if (cpp_macro_p (node))
{
if (pfile->cb.undef)
pfile->cb.undef (pfile, pfile->directive_line, node);
if (CPP_OPTION (pfile, warn_unused_macros))
_cpp_warn_if_unused_macro (pfile, node, NULL);
+ _cpp_free_definition (node);
}
- if (node->type != NT_VOID)
- _cpp_free_definition (node);
if (c->is_undef)
return;
+
{
size_t namelen;
const uchar *dn;
@@ -2530,8 +2497,6 @@ cpp_pop_definition (cpp_reader *pfile, struct def_pragma_macro *c)
h = cpp_lookup (pfile, c->definition, namelen);
dn = c->definition + namelen;
- h->type = NT_VOID;
- h->flags &= ~(NODE_POISONED|NODE_BUILTIN|NODE_DISABLED|NODE_USED);
nbuf = cpp_push_buffer (pfile, dn, ustrchr (dn, '\n') - dn, true);
if (nbuf != NULL)
{