aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-06-28 19:03:08 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-06-28 19:03:08 +0000
commitd4506961cd58fde924aa6561e8896e18161b82ad (patch)
tree82b11e25ea2057714b83389ff3651dad11f94f5e /gcc/cppinit.c
parent47ec19c5bb9a7992d1a5f2a561df3b47dd6ea539 (diff)
downloadgcc-d4506961cd58fde924aa6561e8896e18161b82ad.zip
gcc-d4506961cd58fde924aa6561e8896e18161b82ad.tar.gz
gcc-d4506961cd58fde924aa6561e8896e18161b82ad.tar.bz2
cppfiles.c (open_include_file): If open(2) returns EMFILE or ENFILE...
* cppfiles.c (open_include_file): If open(2) returns EMFILE or ENFILE, close all cached file descriptors and try again. (_cpp_execute_include): Keep a count of the number of times each header is included. (close_cached_fd): New function. * cpphash.h (struct include_file): Rename before to include_count; all users updated. Make include_count and sysp unsigned short. * cppinit.c (cpp_finish): If -H, report headers that could use reinclude guards. (report_missing_guard): New function. From-SVN: r34760
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index e21c566..0cbccae 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -227,6 +227,7 @@ static int opt_comp PARAMS ((const void *, const void *));
#endif
static int parse_option PARAMS ((const char *));
static int handle_option PARAMS ((cpp_reader *, int, char **));
+static int report_missing_guard PARAMS ((splay_tree_node, void *));
/* Fourth argument to append_include_chain: chain to use */
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
@@ -1003,6 +1004,27 @@ cpp_start_read (pfile, print, fname)
return 1;
}
+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;
+}
+
/* This is called at the end of preprocessing. It pops the
last buffer and writes dependency output. It should also
clear macro definitions, such that you could call cpp_start_read
@@ -1055,6 +1077,14 @@ cpp_finish (pfile, print)
if (ferror (print->outf) || fclose (print->outf))
cpp_notice_from_errno (pfile, CPP_OPTION (pfile, out_fname));
}
+
+ /* Report on headers that could use multiple include guards. */
+ if (CPP_OPTION (pfile, print_include_names))
+ {
+ int banner = 0;
+ splay_tree_foreach (pfile->all_include_files, report_missing_guard,
+ (void *) &banner);
+ }
}
static void