From 93d45d9eda934cf8d9ab3e4e4c81fce9ed994a07 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 2 Apr 2008 20:42:53 +0100 Subject: cppopts.texi (-dU): Document. 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. From-SVN: r133847 --- libcpp/expr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libcpp/expr.c') diff --git a/libcpp/expr.c b/libcpp/expr.c index 9df7533..9e89dd9 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -637,6 +637,20 @@ parse_defined (cpp_reader *pfile) "this use of \"defined\" may not be portable"); _cpp_mark_macro_used (node); + if (!(node->flags & NODE_USED)) + { + node->flags |= NODE_USED; + if (node->type == NT_MACRO) + { + 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); + } + } /* A possible controlling macro of the form #if !defined (). _cpp_parse_expr checks there was no other junk on the line. */ -- cgit v1.1