diff options
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) |