aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
Diffstat (limited to 'string')
-rw-r--r--string/bug-strpbrk1.c8
-rw-r--r--string/bug-strspn1.c8
2 files changed, 16 insertions, 0 deletions
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;