warning-poison-system-directories.c 1.9 KB

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