This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Darwin, testsuite, committed] Fix Wnonnull on Darwin.
- From: Iain Sandoe <iain at sandoe dot co dot uk>
- To: GCC-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Martin Sebor <msebor at gmail dot com>
- Date: Sat, 19 Oct 2019 08:55:08 +0100
- Subject: [Darwin, testsuite, committed] Fix Wnonnull on Darwin.
This test has failed always on Darwin, because Darwin does not mark
entries in string.h with nonnull attributes. Since the purpose of the test
is to check that the warnings are issued for an inlined function, not that
the target headers are marked up, we can provide locally marked up
function declarations for Darwin.
tested on x68_64-darwin16, x86_64-linux-gnu,
applied to mainline,
thanks,
Iain.
gcc/testsuite/ChangeLog:
2019-10-19 Iain Sandoe <iain@sandoe.co.uk>
* gcc.dg/Wnonnull.c: Add attributed function declarations for
memcpy and strlen for Darwin.
diff --git a/gcc/testsuite/gcc.dg/Wnonnull.c b/gcc/testsuite/gcc.dg/Wnonnull.c
index be89a5a755..a165baa99f 100644
--- a/gcc/testsuite/gcc.dg/Wnonnull.c
+++ b/gcc/testsuite/gcc.dg/Wnonnull.c
@@ -2,7 +2,16 @@
{ 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 void *memcpy (void *__restrict __dest, const void *__restrict __src,
+ size_t __n) __attribute ((nonnull (1, 2)));
+#endif
char buf[100];