aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2019-10-22 03:40:26 +0000
committerIain Sandoe <iains@gcc.gnu.org>2019-10-22 03:40:26 +0000
commit24b54eb2fd9ee616d899683a459756072e3a1c4d (patch)
tree993f780df5c4b46bc63d3bcdd2ca6dc842552ac3 /gcc
parent8c72657917ad7b9160c36a5b7b240b3389da8eec (diff)
downloadgcc-24b54eb2fd9ee616d899683a459756072e3a1c4d.zip
gcc-24b54eb2fd9ee616d899683a459756072e3a1c4d.tar.gz
gcc-24b54eb2fd9ee616d899683a459756072e3a1c4d.tar.bz2
[testsuite] Make the Wnonnull independent of system headers.
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. gcc/testsuite/ChangeLog: 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. From-SVN: r277280
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/Wnonnull.c16
2 files changed, 10 insertions, 11 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5aec5cd..d63c7b5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2019-10-21 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/parse/qualified2.C: Tighten dg-error directive.
diff --git a/gcc/testsuite/gcc.dg/Wnonnull.c b/gcc/testsuite/gcc.dg/Wnonnull.c
index a165baa..0ed06aa 100644
--- a/gcc/testsuite/gcc.dg/Wnonnull.c
+++ b/gcc/testsuite/gcc.dg/Wnonnull.c
@@ -2,16 +2,10 @@
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
-#ifndef __APPLE__
-#include <string.h>
-#else
-/* OSX headers do not mark up the nonnull elements yet. */
-# include <stddef.h>
-extern size_t strlen (const char *__s)
- __attribute ((pure)) __attribute ((nonnull (1)));
+extern __SIZE_TYPE__ strlen (const char *__s)
+ __attribute ((pure)) __attribute ((nonnull (1)));
extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
- size_t __n) __attribute ((nonnull (1, 2)));
-#endif
+ __SIZE_TYPE__ __n) __attribute ((nonnull (1, 2)));
char buf[100];
@@ -23,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