diff options
author | Ben Elliston <bje@au.ibm.com> | 2004-05-22 02:39:35 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2004-05-22 12:39:35 +1000 |
commit | b02398bd5bebe35bc44def2963fee7a4c4cf3568 (patch) | |
tree | 0fb35652621330c19f8e8ce0ffeb987cb15f69d5 /gcc/c-incpath.c | |
parent | 12fea1f9fcb7129531fa3f30a0688a80e68b5353 (diff) | |
download | gcc-b02398bd5bebe35bc44def2963fee7a4c4cf3568.zip gcc-b02398bd5bebe35bc44def2963fee7a4c4cf3568.tar.gz gcc-b02398bd5bebe35bc44def2963fee7a4c4cf3568.tar.bz2 |
c.opt (Wmissing-include-dirs): New.
* c.opt (Wmissing-include-dirs): New.
* c-opts.c (c_common_handle_option): Pass true for user_supplied_p
to add_path () for -I, but false for OPT_idirafter, OPT_iquote and
OPT_isystem. Handle case OPT_Wmissing_include_dirs.
* c-incpath.h (add_path): Add fourth (bool) argument.
* c-incpath.c (add_env_var_paths): Pass false to add_path ().
(add_standard_paths): Likewise.
(remove_duplicates) [REASON_NOENT]: Warn if -Wmissing-include-dirs
is used and the directory was user-supplied via -I.
(add_path): Set p->user_supplied_p. Remove duplicated code by
using add_cpp_dir_path ().
* cpplib.h (struct cpp_options): Add warn_missing_include_dirs.
(struct cpp_dir): Add user_supplied_p.
* doc/invoke.texi (Warning Options): Document new option.
[testsuite]
* gcc.dg/cpp/Wmissingdirs.c: New.
From-SVN: r82121
Diffstat (limited to 'gcc/c-incpath.c')
-rw-r--r-- | gcc/c-incpath.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gcc/c-incpath.c b/gcc/c-incpath.c index b4da86f..ea83c1a 100644 --- a/gcc/c-incpath.c +++ b/gcc/c-incpath.c @@ -114,7 +114,7 @@ add_env_var_paths (const char *env_var, int chain) path[q - p] = '\0'; } - add_path (path, chain, chain == SYSTEM); + add_path (path, chain, chain == SYSTEM, false); } } @@ -142,7 +142,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, int cxx_stdinc) if (!strncmp (p->fname, cpp_GCC_INCLUDE_DIR, len)) { char *str = concat (iprefix, p->fname + len, NULL); - add_path (str, SYSTEM, p->cxx_aware); + add_path (str, SYSTEM, p->cxx_aware, false); } } } @@ -160,7 +160,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, int cxx_stdinc) else str = update_path (p->fname, p->component); - add_path (str, SYSTEM, p->cxx_aware); + add_path (str, SYSTEM, p->cxx_aware, false); } } } @@ -192,7 +192,13 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, if (errno != ENOENT) cpp_errno (pfile, CPP_DL_ERROR, cur->name); else - reason = REASON_NOENT; + { + /* If -Wmissing-include-dirs is given, warn. */ + cpp_options *opts = cpp_get_options (pfile); + if (opts->warn_missing_include_dirs && cur->user_supplied_p) + cpp_errno (pfile, CPP_DL_WARNING, cur->name); + reason = REASON_NOENT; + } } else if (!S_ISDIR (st.st_mode)) cpp_error_with_line (pfile, CPP_DL_ERROR, 0, 0, @@ -317,7 +323,7 @@ add_cpp_dir_path (cpp_dir *p, int chain) /* Add PATH to the include chain CHAIN. PATH must be malloc-ed and NUL-terminated. */ void -add_path (char *path, int chain, int cxx_aware) +add_path (char *path, int chain, int cxx_aware, bool user_supplied_p) { cpp_dir *p; @@ -329,12 +335,9 @@ add_path (char *path, int chain, int cxx_aware) else p->sysp = 0; p->construct = 0; + p->user_supplied_p = user_supplied_p; - if (tails[chain]) - tails[chain]->next = p; - else - heads[chain] = p; - tails[chain] = p; + add_cpp_dir_path (p, chain); } /* Exported function to handle include chain merging, duplicate |