summaryrefslogtreecommitdiffstats
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-02 19:42:53 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-02 19:42:53 +0000
commit34c3de48578a737fce63c51b7a6f63db5c7d43ab (patch)
treef70286f28df6c1a7f1cb8695448540d74ba1f396 /libcpp/macro.c
parent483108791801d42d879b6aa23b1954e1f692d372 (diff)
downloadppe42-gcc-34c3de48578a737fce63c51b7a6f63db5c7d43ab.tar.gz
ppe42-gcc-34c3de48578a737fce63c51b7a6f63db5c7d43ab.zip
gcc:
* doc/cppopts.texi (-dU): Document. * c-common.h (flag_dump_macros): Update comment. * c-opts.c (handle_OPT_d): Handle -dU. * c-ppoutput.c (macro_queue, define_queue, undef_queue, dump_queued_macros, cb_used_define, cb_used_undef): New. (init_pp_output): Handle -dU. (cb_line_change): Call dump_queued_macros. * toplev.c (decode_d_option): Accept -dU as preprocessor option. gcc/testsuite: * gcc.dg/cpp/cmdlne-dU-1.c, gcc.dg/cpp/cmdlne-dU-2.c, gcc.dg/cpp/cmdlne-dU-3.c, gcc.dg/cpp/cmdlne-dU-4.c, gcc.dg/cpp/cmdlne-dU-5.c, gcc.dg/cpp/cmdlne-dU-6.c, gcc.dg/cpp/cmdlne-dU-7.c, gcc.dg/cpp/cmdlne-dU-8.c, gcc.dg/cpp/cmdlne-dU-9.c, gcc.dg/cpp/cmdlne-dU-10.c, gcc.dg/cpp/cmdlne-dU-11.c, gcc.dg/cpp/cmdlne-dU-12.c, gcc.dg/cpp/cmdlne-dU-13.c, gcc.dg/cpp/cmdlne-dU-14.c, gcc.dg/cpp/cmdlne-dU-15.c, gcc.dg/cpp/cmdlne-dU-16.c, gcc.dg/cpp/cmdlne-dU-17.c, gcc.dg/cpp/cmdlne-dU-18.c, gcc.dg/cpp/cmdlne-dU-19.c, gcc.dg/cpp/cmdlne-dU-20.c, gcc.dg/cpp/cmdlne-dU-21.c, gcc.dg/cpp/cmdlne-dU-22.c: New tests. libcpp: * include/cpplib.h (struct cpp_callbacks): Add used_define, used_undef and before_define. (NODE_USED): Define. * directives.c (do_define, do_undef, undefine_macros, do_ifdef, do_ifndef, cpp_pop_definition): Handle new flag and use new callbacks. * expr.c (parse_defined): Handle new flag and use new callbacks. * macro.c (enter_macro_context, _cpp_free_definition): Handle new flag and use new callbacks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133847 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c
index fd624b10110..587b94814cc 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -815,6 +815,13 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
pfile->state.angled_headers = false;
+ if ((node->flags & NODE_BUILTIN) && !(node->flags & NODE_USED))
+ {
+ node->flags |= NODE_USED;
+ if (pfile->cb.used_define)
+ pfile->cb.used_define (pfile, pfile->directive_line, node);
+ }
+
/* Handle standard macros. */
if (! (node->flags & NODE_BUILTIN))
{
@@ -854,6 +861,13 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
/* Disable the macro within its expansion. */
node->flags |= NODE_DISABLED;
+ if (!(node->flags & NODE_USED))
+ {
+ node->flags |= NODE_USED;
+ if (pfile->cb.used_define)
+ pfile->cb.used_define (pfile, pfile->directive_line, node);
+ }
+
macro->used = 1;
if (macro->paramc == 0)
@@ -1393,7 +1407,7 @@ _cpp_free_definition (cpp_hashnode *h)
/* Macros and assertions no longer have anything to free. */
h->type = NT_VOID;
/* Clear builtin flag in case of redefinition. */
- h->flags &= ~(NODE_BUILTIN | NODE_DISABLED);
+ h->flags &= ~(NODE_BUILTIN | NODE_DISABLED | NODE_USED);
}
/* Save parameter NODE to the parameter list of macro MACRO. Returns
OpenPOWER on IntegriCloud