aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/incpath.c
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2016-02-10 14:40:41 -0800
committerCaroline Tice <cmtice@google.com>2016-02-26 08:25:55 -0800
commit817a788f9eb01eff367191401d48f2aaa8d4f428 (patch)
tree637f745404b37fbf3fcff629227d7d542725e5fe /gcc-4.9/gcc/incpath.c
parenta4ca82cac69c3147143d7b4b4d7cdeb5e02f20ef (diff)
downloadtoolchain_gcc-817a788f9eb01eff367191401d48f2aaa8d4f428.tar.gz
toolchain_gcc-817a788f9eb01eff367191401d48f2aaa8d4f428.tar.bz2
toolchain_gcc-817a788f9eb01eff367191401d48f2aaa8d4f428.zip
Unify ChromeOS and Android versions of GCC.
This CL updates Android's GCC to match ChromeOS's GCC (with appropriate patches applied in both places to make sure no cherry-picked changes are lost). Change-Id: I390140c449b0e5df9ee78a06268319c8c510302f
Diffstat (limited to 'gcc-4.9/gcc/incpath.c')
-rw-r--r--gcc-4.9/gcc/incpath.c40
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])