public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: Define _POSIX_C_SOURCE for test
@ 2024-03-10 17:26 Torbjörn SVENSSON
  2024-03-16  9:22 ` [PING] " Torbjorn SVENSSON
  2024-03-17 17:48 ` Mike Stump
  0 siblings, 2 replies; 4+ messages in thread
From: Torbjörn SVENSSON @ 2024-03-10 17:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: mikestump, Torbjörn SVENSSON

Ok for trunk?

--

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>
---
 gcc/testsuite/c-c++-common/analyzer/strndup-1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
index 85ccae85d83..577ece0cfba 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>
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PING] Re: [PATCH] testsuite: Define _POSIX_C_SOURCE for test
  2024-03-10 17:26 [PATCH] testsuite: Define _POSIX_C_SOURCE for test Torbjörn SVENSSON
@ 2024-03-16  9:22 ` Torbjorn SVENSSON
  2024-03-17 17:48 ` Mike Stump
  1 sibling, 0 replies; 4+ messages in thread
From: Torbjorn SVENSSON @ 2024-03-16  9:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: mikestump

Ping!

Kind regards,
Torbjörn

On 2024-03-10 18:26, Torbjörn SVENSSON wrote:
> Ok for trunk?
> 
> --
> 
> 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>
> ---
>   gcc/testsuite/c-c++-common/analyzer/strndup-1.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
> index 85ccae85d83..577ece0cfba 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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] testsuite: Define _POSIX_C_SOURCE for test
  2024-03-10 17:26 [PATCH] testsuite: Define _POSIX_C_SOURCE for test Torbjörn SVENSSON
  2024-03-16  9:22 ` [PING] " Torbjorn SVENSSON
@ 2024-03-17 17:48 ` Mike Stump
  2024-03-18  7:31   ` Torbjorn SVENSSON
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Stump @ 2024-03-17 17:48 UTC (permalink / raw)
  To: Torbjörn SVENSSON; +Cc: gcc-patches

On Mar 10, 2024, at 10:26 AM, Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> wrote:
> 
> Ok for trunk?

Ok.

> 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>
> ---
> gcc/testsuite/c-c++-common/analyzer/strndup-1.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
> index 85ccae85d83..577ece0cfba 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>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] testsuite: Define _POSIX_C_SOURCE for test
  2024-03-17 17:48 ` Mike Stump
@ 2024-03-18  7:31   ` Torbjorn SVENSSON
  0 siblings, 0 replies; 4+ messages in thread
From: Torbjorn SVENSSON @ 2024-03-18  7:31 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches



On 2024-03-17 18:48, Mike Stump wrote:
> On Mar 10, 2024, at 10:26 AM, Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> wrote:
>>
>> Ok for trunk?
> 
> Ok.

Pushed as basepoints/gcc-14-9513-g58753dba800 to trunk.

Kind regards,
Torbjörn

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-18  7:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10 17:26 [PATCH] testsuite: Define _POSIX_C_SOURCE for test Torbjörn SVENSSON
2024-03-16  9:22 ` [PING] " Torbjorn SVENSSON
2024-03-17 17:48 ` Mike Stump
2024-03-18  7:31   ` Torbjorn SVENSSON

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).