diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-07-05 05:33:57 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-05 05:33:57 +0000 |
commit | c71f835b2549f6b787732b5e326c5c23dbb1f66b (patch) | |
tree | 0faabdcd2aa742b82e58d484b96722dd2b861e6e /gcc/cppfiles.c | |
parent | 1bbee75bcc0d3948fb1e55da6a3547cddeb000a0 (diff) | |
download | gcc-c71f835b2549f6b787732b5e326c5c23dbb1f66b.zip gcc-c71f835b2549f6b787732b5e326c5c23dbb1f66b.tar.gz gcc-c71f835b2549f6b787732b5e326c5c23dbb1f66b.tar.bz2 |
cpplex.c: Don't include sys/mman.h.
toplevel:
* cpplex.c: Don't include sys/mman.h.
(cpp_push_buffer, cpp_pop_buffer): Moved to cpplib.c.
* cpplib.c: Include sys/mman.h and obstack.h.
(cpp_push_buffer): Moved from cpplex.c; allocate buffers on an
obstack.
(cpp_pop_buffer): Moved from cpplex.c; free buffers from an obstack.
(_cpp_unwind_if_stack): Now static, unwind_if_stack. Don't
bother freeing if stack entries (they will be freed with their buffer).
(do_endif): Free if stack entries from the buffer obstack.
(push_conditional): Allocate if stack entries from the buffer obstack.
(find_answer): Rename to _cpp_find_answer.
(do_assert, do_unassert): Update.
* cpphash.h: Update prototypes.
(xobnew): New convenience macro.
* cpplib.h (struct cpp_reader): Add hash_ob and buffer_ob fields.
Update comments.
(struct cpp_hashnode): Remove disabled field.
* cppinit.c: Don't include hashtab.h or splay-tree.h.
(report_missing_guard): Moved to cppfiles.c.
(cpp_reader_init): Call cpp_init_stacks, cpp_init_macros,
cpp_init_includes.
(cpp_cleanup): Call cpp_cleanup_stacks, cpp_cleanup_macros,
cpp_cleanup_includes. Don't destroy hashtab or
all_include_files here.
(cpp_finish): Use _cpp_report_missing_guards.
* cppfiles.c (report_missing_guard): Moved from cppinit.c.
(_cpp_init_include_table): Rename _cpp_init_includes.
(_cpp_cleanup_includes, _cpp_report_missing_guards): New.
* cppexp.c (parse_assertion): Update for new name of
find_answer.
* Makefile.in (cpplib.o, cpphash.o, cppinit.o): Update deps.
* cpplib.c (do_ident): s/VSPACE/EOF/
testsuite:
* gcc.dg/cpp/ident.c: New test.
From-SVN: r34870
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r-- | gcc/cppfiles.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 66fb7bc..4170641 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -60,7 +60,8 @@ static ssize_t read_with_read PARAMS ((cpp_buffer *, int, ssize_t)); static ssize_t read_file PARAMS ((cpp_buffer *, int, ssize_t)); static void destroy_include_file_node PARAMS ((splay_tree_value)); -static int close_cached_fd PARAMS ((splay_tree_node, void *)); +static int close_cached_fd PARAMS ((splay_tree_node, void *)); +static int report_missing_guard PARAMS ((splay_tree_node, void *)); #if 0 static void hack_vms_include_specification PARAMS ((char *)); @@ -103,7 +104,7 @@ close_cached_fd (n, dummy) } void -_cpp_init_include_table (pfile) +_cpp_init_includes (pfile) cpp_reader *pfile; { pfile->all_include_files @@ -112,6 +113,13 @@ _cpp_init_include_table (pfile) destroy_include_file_node); } +void +_cpp_cleanup_includes (pfile) + cpp_reader *pfile; +{ + splay_tree_delete (pfile->all_include_files); +} + /* Given a filename, look it up and possibly open it. If the file does not exist, return NULL. If the file does exist but doesn't need to be reread, return an include_file entry with fd == -1. @@ -358,6 +366,38 @@ cpp_make_system_header (pfile, pbuf, flag) pbuf->inc->sysp = flag; } +/* Report on all files that might benefit from a multiple include guard. + Triggered by -H. */ +void +_cpp_report_missing_guards (pfile) + cpp_reader *pfile; +{ + int banner = 0; + splay_tree_foreach (pfile->all_include_files, report_missing_guard, + (PTR) &banner); +} + +static int +report_missing_guard (n, b) + splay_tree_node n; + void *b; +{ + struct include_file *f = (struct include_file *) n->value; + int *bannerp = (int *)b; + + if (f && f->cmacro == 0 && f->include_count == 1) + { + if (*bannerp == 0) + { + fputs (_("Multiple include guards may be useful for:\n"), stderr); + *bannerp = 1; + } + fputs (f->name, stderr); + putc ('\n', stderr); + } + return 0; +} + #define PRINT_THIS_DEP(p, b) (CPP_PRINT_DEPS(p) > (b||p->system_include_depth)) void _cpp_execute_include (pfile, f, len, no_reinclude, search_start, angle_brackets) |