about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--string/bug-strpbrk1.c8
-rw-r--r--string/bug-strspn1.c8
3 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 479e90fbf3..ce0266a35e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-06-20  Joseph Myers  <joseph@codesourcery.com>
+
+	* string/bug-strpbrk1.c: Include <libc-diag.h>.
+	(main): Disable -Wunused-value around call to strpbrk.
+	* string/bug-strspn1.c: Include <libc-diag.h>.
+	(main): Disable -Wunused-value around call to strspn.
+
 2018-06-20  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
 	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
diff --git a/string/bug-strpbrk1.c b/string/bug-strpbrk1.c
index 28238b0f50..8e909a1e21 100644
--- a/string/bug-strpbrk1.c
+++ b/string/bug-strpbrk1.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (void)
@@ -11,7 +12,14 @@ main (void)
   const char *a = "abc";
   const char *b = a;
 
+  DIAG_PUSH_NEEDS_COMMENT;
+  /* GCC 9 correctly warns that this call to strpbrk is useless.  That
+     is deliberate; this test is verifying that a side effect in an
+     argument still occurs when the call itself is useless and could
+     be optimized to return a constant.  */
+  DIAG_IGNORE_NEEDS_COMMENT (9, "-Wunused-value");
   strpbrk (b++, "");
+  DIAG_POP_NEEDS_COMMENT;
   if (b != a + 1)
     return 1;
 
diff --git a/string/bug-strspn1.c b/string/bug-strspn1.c
index a657bafc43..e3487ab8f9 100644
--- a/string/bug-strspn1.c
+++ b/string/bug-strspn1.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (void)
@@ -11,7 +12,14 @@ main (void)
   const char *a = "abc";
   const char *b = a;
 
+  DIAG_PUSH_NEEDS_COMMENT;
+  /* GCC 9 correctly warns that this call to strspn is useless.  That
+     is deliberate; this test is verifying that a side effect in an
+     argument still occurs when the call itself is useless and could
+     be optimized to return a constant.  */
+  DIAG_IGNORE_NEEDS_COMMENT (9, "-Wunused-value");
   strspn (b++, "");
+  DIAG_POP_NEEDS_COMMENT;
   if (b != a + 1)
     return 1;