Skip to content
Snippets Groups Projects
  • Torbjörn SVENSSON's avatar
    58753dba
    testsuite: Define _POSIX_C_SOURCE for test · 58753dba
    Torbjörn SVENSSON authored
    
    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: default avatarTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
    58753dba
    History
    testsuite: Define _POSIX_C_SOURCE for test
    Torbjörn SVENSSON authored
    
    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: default avatarTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>