1 // REQUIRES: x86-registered-target
2 
3 // System directory and sysroot option causes warning.
4 // RUN: %clang -Wpoison-system-directories -target x86_64 -I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
5 // RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
6 // RUN: %clang -Wpoison-system-directories -target x86_64 -cxx-isystem/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
7 // RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
8 // RUN: %clang -Wpoison-system-directories -target x86_64 -iquote/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
9 // RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
10 // RUN: %clang -Wpoison-system-directories -target x86_64 -isystem/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
11 // RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
12 
13 // Missing target but included sysroot still causes the warning.
14 // RUN: %clang -Wpoison-system-directories -I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.2.stderr
15 // RUN: FileCheck -check-prefix=WARN < %t.2.stderr %s
16 
17 // With -Werror the warning causes the failure.
18 // RUN: not %clang -Werror=poison-system-directories -target x86_64 -I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.3.stderr
19 // RUN: FileCheck -check-prefix=ERROR < %t.3.stderr %s
20 
21 // Cros target without sysroot causes no warning.
22 // RUN: %clang -Wpoison-system-directories -Werror -target x86_64 -I/usr/include -c -o - %s
23 
24 // By default the warning is off.
25 // RUN: %clang -Werror -target x86_64 -I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s
26 
27 // WARN: warning: include location {{[^ ]+}} is unsafe for cross-compilation [-Wpoison-system-directories]
28 
29 // ERROR: error: include location {{[^ ]+}} is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]
30