diff options
author | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2024-03-10 18:18:51 +0100 |
---|---|---|
committer | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2024-03-18 08:29:47 +0100 |
commit | 58753dba800de14144785199fd710e9b00544155 (patch) | |
tree | 776c297f525cc35006ab5733df51fbe33885d588 | |
parent | 942d470a5a4fb1baeff943127a81b441dffaa543 (diff) | |
download | gcc-58753dba800de14144785199fd710e9b00544155.zip gcc-58753dba800de14144785199fd710e9b00544155.tar.gz gcc-58753dba800de14144785199fd710e9b00544155.tar.bz2 |
testsuite: Define _POSIX_C_SOURCE for test
As the tests assume that strndup() is visible (only part of
POSIX.1-2008) define the guard to ensure that it's visible. Currently,
glibc appears to always have this defined in C++, newlib does not.
Without this patch, fails like this can be seen:
Testing analyzer/strndup-1.c, -std=c++98
.../strndup-1.c: In function 'void test_1(const char*)':
.../strndup-1.c:11:13: error: 'strndup' was not declared in this scope; did you mean 'strncmp'?
.../strndup-1.c: In function 'void test_2(const char*)':
.../strndup-1.c:16:13: error: 'strndup' was not declared in this scope; did you mean 'strncmp'?
.../strndup-1.c: In function 'void test_3(const char*)':
.../strndup-1.c:21:13: error: 'strndup' was not declared in this scope; did you mean 'strncmp'?
Patch has been verified on Linux.
gcc/testsuite/ChangeLog:
* c-c++-common/analyzer/strndup-1.c: Define _POSIX_C_SOURCE.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
-rw-r--r-- | gcc/testsuite/c-c++-common/analyzer/strndup-1.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c index 85ccae8..577ece0 100644 --- a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c @@ -1,4 +1,5 @@ /* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* hppa*-*-hpux* *-*-mingw* *-*-vxworks* } } */ +/* { dg-additional-options "-D_POSIX_C_SOURCE=200809L" } */ #include <string.h> #include <stdlib.h> |