diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2002-07-23 22:57:49 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-07-23 22:57:49 +0000 |
commit | a69cbaac60d73feb37e6c17abd6f84991dc791a0 (patch) | |
tree | d7305615fe0d53e288982b583d2c9c637deb2699 /gcc/cpphash.h | |
parent | b841421a28b7e7c616e58cae4b5e36599f288b7f (diff) | |
download | gcc-a69cbaac60d73feb37e6c17abd6f84991dc791a0.tar.gz |
cppexp.c (parse_defined): Mark macro used.
* cppexp.c (parse_defined): Mark macro used.
* cpphash.h (struct cpp_macro): New member "used".
(_cpp_mark_macro_used, _cpp_warn_if_unused_macro): New.
(struct cpp_reader): New member.
* cppinit.c (cpp_finish_options): Set first_unused_line.
(cpp_finish): Warn of unused macros if requested.
(OPT_TABLE): New switches.
(cpp_handle_option): Handle them.
* cpplib.c (do_undef): Warn if macro unused.
(do_ifdef, do_ifndef): Mark macro used.
* cpplib.h (struct cpp_options): New member.
* cppmacro.c (_cpp_warn_if_unused_macro): New.
(enter_macro_context): Mark macro used.
(_cpp_create_definition): Mark macro unused; warn if unused
when redefined.
* cpptrad.c (scan_out_logcial_line, push_replacement_text):
Mark macros used.
* doc/cppopts.texi: Update.
testsuite:
* gcc.dg/cpp/trad/Wunused.c, gcc.dg/cpp/trad/Wunused.h,
gcc.dg/cpp/Wunused.c, gcc.dg/cpp/Wunused.h: New tests.
From-SVN: r55692
Diffstat (limited to 'gcc/cpphash.h')
-rw-r--r-- | gcc/cpphash.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cpphash.h b/gcc/cpphash.h index 133c9b93015..5e69c853b98 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -98,8 +98,15 @@ struct cpp_macro /* If macro defined in system header. */ unsigned int syshdr : 1; + + /* Non-zero if it has been expanded or had its existence tested. */ + unsigned int used : 1; }; +#define _cpp_mark_macro_used(NODE) do { \ + if ((NODE)->type == NT_MACRO && !((NODE)->flags & NODE_BUILTIN)) \ + (NODE)->value.macro->used = 1; } while (0) + /* A generic memory buffer, and operations on it. */ typedef struct _cpp_buff _cpp_buff; struct _cpp_buff @@ -370,6 +377,9 @@ struct cpp_reader for include files. (Altered as we get more of them.) */ unsigned int max_include_len; + /* Macros on or after this line are warned about if unused. */ + unsigned int first_unused_line; + /* Date and time text. Calculated together if either is requested. */ const uchar *date; const uchar *time; @@ -477,6 +487,8 @@ extern bool _cpp_arguments_ok PARAMS ((cpp_reader *, cpp_macro *, unsigned int)); extern const uchar *_cpp_builtin_macro_text PARAMS ((cpp_reader *, cpp_hashnode *)); +int _cpp_warn_if_unused_macro PARAMS ((cpp_reader *, cpp_hashnode *, + void *)); /* In cpphash.c */ extern void _cpp_init_hashtable PARAMS ((cpp_reader *, hash_table *)); extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *)); |