diff options
author | bje <bje@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-22 02:39:35 +0000 |
---|---|---|
committer | bje <bje@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-05-22 02:39:35 +0000 |
commit | 06fd18c9e3c5c0af056bda9beef74491532a973e (patch) | |
tree | 0fb35652621330c19f8e8ce0ffeb987cb15f69d5 /gcc/c-incpath.c | |
parent | 9d14ee5b811b69317eaf95df692191783e071be8 (diff) | |
download | gcc-06fd18c9e3c5c0af056bda9beef74491532a973e.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82121 138bc75d-0d04-0410-961f-82ee72b054a4
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 b4da86fb7ba..ea83c1a18b4 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 |