public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2022-10-28 17:47 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2022-10-28 17:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=99b3f8be01fa2f66ee23287d66ea432cb2f71bba

commit 99b3f8be01fa2f66ee23287d66ea432cb2f71bba
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index 7bfe9b2b8d..27f8670553 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 static char buf[8192];
 
@@ -28,7 +29,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index bab062d992..2eeb6ed7b0 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 
 int
@@ -53,6 +54,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -100,6 +106,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8d7f2375fa..7f784e7180 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2024-04-17 20:13 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:13 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d57642f9fa4bb0a21c37ef0b19965c62c16ae46a

commit d57642f9fa4bb0a21c37ef0b19965c62c16ae46a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 67fbe4e1de..8e501ba20f 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index b2e8263283..c0a64d22c7 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2024-04-02 15:59 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:59 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=46b30fe8b9bbf38a86e04dbbe49e32afae68267a

commit 46b30fe8b9bbf38a86e04dbbe49e32afae68267a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 67fbe4e1de..8e501ba20f 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index b2e8263283..c0a64d22c7 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2024-02-09 17:37 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:37 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ec891e8549d968978d129de67ea4ccf579953d4e

commit ec891e8549d968978d129de67ea4ccf579953d4e
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 67fbe4e1de..8e501ba20f 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index b2e8263283..c0a64d22c7 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2024-02-07 14:13 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:13 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c60c8cf5f23d7ca76b7bf2f56724a22c9fa26f73

commit c60c8cf5f23d7ca76b7bf2f56724a22c9fa26f73
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 67fbe4e1de..8e501ba20f 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index b2e8263283..c0a64d22c7 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2024-01-29 18:03 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 18:03 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f90df7d87ed46f891c784dafb3034340f51cf104

commit f90df7d87ed46f891c784dafb3034340f51cf104
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 67fbe4e1de..8e501ba20f 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index b2e8263283..c0a64d22c7 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2023-12-21 18:59 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:59 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b28e3e97778d52bbac931eb3b7a2ecdf3b12e9dc

commit b28e3e97778d52bbac931eb3b7a2ecdf3b12e9dc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 0544916eb1..8783f53b35 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8c633cf455..f409597c94 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2023-09-28 17:58 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:58 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b4d12698e4845f89a8c2a164df3259e56f47e1eb

commit b4d12698e4845f89a8c2a164df3259e56f47e1eb
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 0544916eb1..8783f53b35 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8c633cf455..f409597c94 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2023-08-30 12:42 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2023-08-30 12:42 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3ed0052c10bd676b41649aa6552a170f07c88e90

commit 3ed0052c10bd676b41649aa6552a170f07c88e90
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index dfa19aed55..c46810f94c 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 #include <support/support.h>
 
@@ -30,7 +31,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 0544916eb1..8783f53b35 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #include <support/xstdio.h>
 
@@ -54,6 +55,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -101,6 +107,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8c633cf455..f409597c94 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2023-02-09 19:54 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2023-02-09 19:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=82c149d977bc3a40d3f7bfca1580c4578ec1bd5b

commit 82c149d977bc3a40d3f7bfca1580c4578ec1bd5b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index 7bfe9b2b8d..27f8670553 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 static char buf[8192];
 
@@ -28,7 +29,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index 7825ca9358..6115c2c8eb 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 
 int
@@ -53,6 +54,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -100,6 +106,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8c633cf455..f409597c94 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [glibc/azanella/clang] stdio: Suppress %Z format for clang
@ 2022-10-04 13:05 Adhemerval Zanella
  0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2022-10-04 13:05 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3a4e0697640b58a95b18b35ee90d374aea1899f4

commit 3a4e0697640b58a95b18b35ee90d374aea1899f4
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Sep 1 09:29:23 2022 -0300

    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 thrown a more generic warning.

Diff:
---
 stdio-common/bug1.c      | 11 +++++++++++
 stdio-common/bug5.c      |  6 ++++++
 stdio-common/test_rdwr.c |  7 +++++++
 stdio-common/tst-fphex.c |  5 +++++
 stdio-common/tstgetln.c  |  6 ++++++
 5 files changed, 35 insertions(+)

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);
 
diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c
index 7bfe9b2b8d..27f8670553 100644
--- a/stdio-common/bug5.c
+++ b/stdio-common/bug5.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libc-diag.h>
 
 static char buf[8192];
 
@@ -28,7 +29,12 @@ main (void)
       return 1;
     }
   for (i = 0; i < 1000; ++i)
+    /* 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");
     fprintf (in, "%Zu\n", i);
+    DIAG_POP_NEEDS_COMMENT_CLANG;
 
   out = fopen (outname, "w");
   if (out == NULL)
diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c
index bab062d992..2eeb6ed7b0 100644
--- a/stdio-common/test_rdwr.c
+++ b/stdio-common/test_rdwr.c
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 
 int
@@ -53,6 +54,11 @@ main (int argc, char **argv)
   rewind (f);
   (void) fputs (buf, f);
   rewind (f);
+
+  /* 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");
   {
     size_t i;
     for (i = 0; i < replace_from; ++i)
@@ -100,6 +106,7 @@ main (int argc, char **argv)
 	lose = 1;
       }
   }
+  DIAG_POP_NEEDS_COMMENT_CLANG;
 
   if (!lose)
     {
diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c
index efba482537..7c0e4bd6fc 100644
--- a/stdio-common/tst-fphex.c
+++ b/stdio-common/tst-fphex.c
@@ -3,6 +3,7 @@
 #include <array_length.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-diag.h>
 
 #ifndef WIDE
 # define STR_LEN strlen
@@ -56,10 +57,14 @@ do_test (void)
       int n = SPRINT (buf, array_length (buf), t->fmt, t->value);
       if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0)
 	{
+	  /* clang do not handle %Z format.  */
+	  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+	  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat");
 	  PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot      \""
 		    S "\" (%d, %Zu)\n"),
 		 t->fmt, t->expect, STR_LEN (t->expect),
 		 buf, n, STR_LEN (buf));
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	  result = 1;
 	}
     }
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 8d7f2375fa..7f784e7180 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -16,6 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <libc-diag.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,12 @@ main (int argc, char *argv[])
 
   while ((len = getline (&buf, &size, stdin)) != -1)
     {
+      /* 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 ("bufsize %Zu; read %Zd: ", size, len);
+      DIAG_POP_NEEDS_COMMENT_CLANG;
       if (fwrite (buf, len, 1, stdout) != 1)
 	{
 	  perror ("fwrite");

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-04-17 20:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 17:47 [glibc/azanella/clang] stdio: Suppress %Z format for clang Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:13 Adhemerval Zanella
2024-04-02 15:59 Adhemerval Zanella
2024-02-09 17:37 Adhemerval Zanella
2024-02-07 14:13 Adhemerval Zanella
2024-01-29 18:03 Adhemerval Zanella
2023-12-21 18:59 Adhemerval Zanella
2023-09-28 17:58 Adhemerval Zanella
2023-08-30 12:42 Adhemerval Zanella
2023-02-09 19:54 Adhemerval Zanella
2022-10-04 13:05 Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).