For the test to succeed there needs to be some header that is to be found in the 'expected' place i.e. <sysroot>/usr/include/. It's important that it is not the name of a header for which fixincludes have been applied, since such headers will be found in the gcc include-fixed dir and, in general, reference additional headers. The dummy sysroot will prevent the additional headers from being found, resulting in a failed test. The fix is to use a header name that isn’t expected to be present in a real sysroot.
tested on x86_64-darwin18, x86_64-darwin16, applied to mainline thanks Iain 2019-06-24 Iain Sandoe <i...@sandoe.co.uk> * gcc.dg/cpp/isysroot-1.c (main): Use <example.h> as the test header. * gcc.dg/cpp/usr/include/stdio.h: Rename... * gcc.dg/cpp/usr/include/example.h: ... to this. diff --git a/gcc/testsuite/gcc.dg/cpp/isysroot-1.c b/gcc/testsuite/gcc.dg/cpp/isysroot-1.c index 7263ce4..4c54f9e 100644 --- a/gcc/testsuite/gcc.dg/cpp/isysroot-1.c +++ b/gcc/testsuite/gcc.dg/cpp/isysroot-1.c @@ -1,10 +1,17 @@ /* { dg-options "-isysroot ${srcdir}/gcc.dg/cpp" } */ /* { dg-do compile { target *-*-darwin* } } */ -#include <stdio.h> +/* For the test to succeed there needs to be some header that is to be found + in the 'expected' place i.e. <sysroot>/usr/include/. It's important that + it is not the name of a header for which fixincludes have been applied, + since such headers will be found in the gcc include-fixed dir and, in + general, reference additional headers. The dummy sysroot will prevent the + additional headers from being found, resulting in a failed test. So use + a header name we don't expect to see. */ +#include <example.h> int main() { - /* Special stdio.h supplies function foo. */ + /* Special example.h supplies function foo. */ void (*x)(void) = foo; return 0; } diff --git a/gcc/testsuite/gcc.dg/cpp/usr/include/example.h b/gcc/testsuite/gcc.dg/cpp/usr/include/example.h new file mode 100644 index 0000000..c674e89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/usr/include/example.h @@ -0,0 +1,4 @@ +/* Used by gcc.dg/cpp/isysroot-1.c to test isysroot. */ +void foo() +{ +} diff --git a/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h b/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h deleted file mode 100644 index c674e89..0000000 --- a/gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Used by gcc.dg/cpp/isysroot-1.c to test isysroot. */ -void foo() -{ -}