]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[testsuite] Make the Wnonnull test independent of system headers.
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 30 Oct 2019 20:54:16 +0000 (20:54 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Wed, 30 Oct 2019 20:54:16 +0000 (20:54 +0000)
This backports two patches that fix failure of Wnonnull test on some targets.

277280 To avoid the result of this test depending on the implementation of
the system 'string.h', provide prototypes for the two functions used
in the test.  This generalises the fix from 277202.

277202 was the initial fix for Wnonnull on Darwin.

gcc/testsuite/

2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>

Backport from mainline.
2019-10-22  Iain Sandoe  <iain@sandoe.co.uk>

* gcc.dg/Wnonnull.c: Provide prototypes for strlen and memcpy.
Use __SIZE_TYPE__ instead of size_t.

Backport from mainline.
2019-10-19  Iain Sandoe  <iain@sandoe.co.uk>

* gcc.dg/Wnonnull.c: Add attributed function declarations for
memcpy and strlen for Darwin.

From-SVN: r277647

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wnonnull.c

index f04dae4ebd1f2b5da3791225164dd36d0c332757..b21af8bcab55e008ca84452877b7a4a39afb862c 100644 (file)
@@ -1,3 +1,17 @@
+2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
+
+       Backport from mainline.
+       2019-10-22  Iain Sandoe  <iain@sandoe.co.uk>
+
+       * gcc.dg/Wnonnull.c: Provide prototypes for strlen and memcpy.
+       Use __SIZE_TYPE__ instead of size_t.
+
+       Backport from mainline.
+       2019-10-19  Iain Sandoe  <iain@sandoe.co.uk>
+
+       * gcc.dg/Wnonnull.c: Add attributed function declarations for
+       memcpy and strlen for Darwin.
+
 2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline.
index be89a5a755cf524628f87120089cc5134a759edf..0ed06aabe68cf7fa1e90e4526b862dfe8eb6ad51 100644 (file)
@@ -2,7 +2,10 @@
    { dg-do compile }
    { dg-options "-O2 -Wall" } */
 
-#include <string.h>
+extern __SIZE_TYPE__ strlen (const char *__s)
+                            __attribute ((pure)) __attribute ((nonnull (1)));
+extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
+                    __SIZE_TYPE__ __n) __attribute ((nonnull (1, 2)));
 
 char buf[100];
 
@@ -14,9 +17,9 @@ struct Test
 
 __attribute ((nonnull (1, 2)))
 inline char*
-my_strcpy (char *restrict dst, const char *restrict src, size_t size)
+my_strcpy (char *restrict dst, const char *restrict src, __SIZE_TYPE__ size)
 {
-  size_t len = strlen (src);        /* { dg-warning "argument 1 null where non-null expected" } */
+  __SIZE_TYPE__ len = strlen (src); /* { dg-warning "argument 1 null where non-null expected" } */
   if (len < size)
     memcpy (dst, src, len + 1);     /* { dg-warning "argument 2 null where non-null expected" } */
   else