aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/bug1.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-09-01 09:29:23 -0300
committerH.J. Lu <hjl.tools@gmail.com>2024-12-22 17:29:28 +0800
commit77c1128bd35009285820a5e92aa585bb74e2a5ae (patch)
treef8c6916372b6368c4e7f7394186bb1025c7ebc55 /stdio-common/bug1.c
parent69c181f2b3c25d5a8149b975167d1925be881acf (diff)
downloadglibc-77c1128bd35009285820a5e92aa585bb74e2a5ae.tar.xz
glibc-77c1128bd35009285820a5e92aa585bb74e2a5ae.zip
stdio: Suppress %Z format for clang
clang does not handle %Z on print, and just suppressing -Wformat-invalid-specifier might trigger another warning for extra arguments (since %Z is ignored). So suppress -Wformat-extra-args as well. For tst-fphex.c a heavy hammer is used since the printf is more complex and clang throws a more generic warning. Reviewed-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'stdio-common/bug1.c')
-rw-r--r--stdio-common/bug1.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/stdio-common/bug1.c b/stdio-common/bug1.c
index 18e7d4c257..f23ee5b6bb 100644
--- a/stdio-common/bug1.c
+++ b/stdio-common/bug1.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <libc-diag.h>
int
main (void)
@@ -13,12 +14,22 @@ main (void)
stream = open_memstream (&bp, &size);
fprintf (stream, "hello");
fflush (stream);
+ /* clang do not handle %Z format. */
+ DIAG_PUSH_NEEDS_COMMENT_CLANG;
+ DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier");
+ DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args");
printf ("buf = %s, size = %Zu\n", bp, size);
+ DIAG_POP_NEEDS_COMMENT_CLANG;
lose |= size != 5;
lose |= strncmp (bp, "hello", size);
fprintf (stream, ", world");
fclose (stream);
+ /* clang do not handle %Z format. */
+ DIAG_PUSH_NEEDS_COMMENT_CLANG;
+ DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier");
+ DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args");
printf ("buf = %s, size = %Zu\n", bp, size);
+ DIAG_POP_NEEDS_COMMENT_CLANG;
lose |= size != 12;
lose |= strncmp (bp, "hello, world", 12);