diff options
author | Caroline Tice <cmtice@google.com> | 2016-02-29 22:49:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-29 22:49:18 +0000 |
commit | 3a800d7d75ceba88429096186a2150a2d938334a (patch) | |
tree | 9d9c36a627f01c31b077cd8253acc681d5cc4bbf /gcc-4.9/gcc/incpath.c | |
parent | b9de1157289455b0ca26daff519d4a0ddcd1fa13 (diff) | |
parent | 817a788f9eb01eff367191401d48f2aaa8d4f428 (diff) | |
download | toolchain_gcc-3a800d7d75ceba88429096186a2150a2d938334a.tar.gz toolchain_gcc-3a800d7d75ceba88429096186a2150a2d938334a.tar.bz2 toolchain_gcc-3a800d7d75ceba88429096186a2150a2d938334a.zip |
Merge "Unify ChromeOS and Android versions of GCC."
Diffstat (limited to 'gcc-4.9/gcc/incpath.c')
-rw-r--r-- | gcc-4.9/gcc/incpath.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/incpath.c b/gcc-4.9/gcc/incpath.c index ddd856cb7..c25a37659 100644 --- a/gcc-4.9/gcc/incpath.c +++ b/gcc-4.9/gcc/incpath.c @@ -28,6 +28,7 @@ #include "intl.h" #include "incpath.h" #include "cppdefault.h" +#include "diagnostic.h" /* Microsoft Windows does not natively support inodes. VMS has non-numeric inodes. */ @@ -348,6 +349,45 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) add_sysroot_to_chain (sysroot, AFTER); } + /* Need to run here before processing below as that'll automatically cull + paths that do not exist. However, we want to throw errors whenever the + build includes things like -I/usr/include/asdf even if it happens to not + exist on the current system. */ + if (flag_poison_system_directories) + { + unsigned int c; + unsigned int chains[] = { QUOTE, BRACKET, SYSTEM, AFTER }; + + /* Enable -Werror=poison-system-directories when -Werror and -Wno-error + have not been set. + + Ideally this would be done in toplev's process_options, but this + function runs before that one, so we inline it here instead. */ + if (POISON_SYSTEM_DIRECTORIES_DEFAULT + && !global_options_set.x_warnings_are_errors + && global_dc->classify_diagnostic[OPT_Wpoison_system_directories] == + DK_UNSPECIFIED) + diagnostic_classify_diagnostic (global_dc, + OPT_Wpoison_system_directories, + DK_ERROR, UNKNOWN_LOCATION); + + for (c = 0; c < ARRAY_SIZE (chains); ++c) + { + unsigned int chain = chains[c]; + struct cpp_dir *p; + + for (p = heads[chain]; p; p = p->next) + if (!strncmp (p->name, "/usr/include", 12) + || !strncmp (p->name, "/usr/local/include", 18) + || !strncmp (p->name, "/usr/X11R6/include", 18) + || !strncmp (p->name, "/lib", 4) + || !strncmp (p->name, "/usr/local/lib", 14)) + warning (OPT_Wpoison_system_directories, + "include location \"%s\" is unsafe for " + "cross-compilation", p->name); + } + } + /* Join the SYSTEM and AFTER chains. Remove duplicates in the resulting SYSTEM chain. */ if (heads[SYSTEM]) |