Message ID | 20241222000509.2205895-35-hjl.tools@gmail.com |
---|---|
State | Accepted |
Commit | 601b3d5db27ff0c7c7406b9af971b1bc7a1e3e49 |
Headers | show |
Series | [01/39] conform: Use -dD instead of -dN on compiler invocation | expand |
"H.J. Lu" <hjl.tools@gmail.com> writes: > From: Adhemerval Zanella <adhemerval.zanella@linaro.org> > > Clang issues the following warning: > > tst-vfprintf-width-i18n.c:51:34: error: invalid conversion specifier '1' > [-Werror,-Wformat-invalid-specifier] > TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16); > ~~^ > > Since it does not how to handle %I. > --- > stdio-common/tst-vfprintf-width-i18n.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/stdio-common/tst-vfprintf-width-i18n.c b/stdio-common/tst-vfprintf-width-i18n.c > index 1be6dd7782..93f8abab56 100644 > --- a/stdio-common/tst-vfprintf-width-i18n.c > +++ b/stdio-common/tst-vfprintf-width-i18n.c > @@ -23,6 +23,7 @@ > #include <stdio.h> > #include <support/support.h> > #include <support/check.h> > +#include <libc-diag.h> > > static int > do_test (void) > @@ -48,6 +49,9 @@ do_test (void) > TEST_COMPARE_STRING (buf, " INR12,345.67"); > > /* Translated. */ > + /* clang does not know about the GNU extension 'I'. */ > + DIAG_PUSH_NEEDS_COMMENT_CLANG; > + DIAG_IGNORE_NEEDS_COMMENT_CLANG (14, "-Wformat-invalid-specifier"); > TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16); > TEST_COMPARE_STRING (buf, " १२३४५"); > TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 26); > @@ -58,6 +62,7 @@ do_test (void) > TEST_COMPARE_STRING (buf, " १२,३४५"); > TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 26); > TEST_COMPARE_STRING (buf, " १२,३४५.६७"); > + DIAG_POP_NEEDS_COMMENT_CLANG; > > xsetlocale (LC_ALL, "ps_AF.UTF-8"); > > @@ -78,6 +83,8 @@ do_test (void) > TEST_COMPARE_STRING (buf, " 12٬346 AFN"); /* Counts bytes. */ > > /* Translated. */ > + DIAG_PUSH_NEEDS_COMMENT_CLANG; > + DIAG_IGNORE_NEEDS_COMMENT_CLANG (14, "-Wformat-invalid-specifier"); > TEST_COMPARE (sprintf (buf, "%I11d", 12345), 11); > TEST_COMPARE_STRING (buf, " ١٢٣۴٥"); > TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 20); > @@ -88,6 +95,7 @@ do_test (void) > TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥"); > TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 21); > TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥٫٦٧"); > + DIAG_POP_NEEDS_COMMENT_CLANG; > > return 0; > } Reviewed-by: Sam James <sam@gentoo.org>
diff --git a/stdio-common/tst-vfprintf-width-i18n.c b/stdio-common/tst-vfprintf-width-i18n.c index 1be6dd7782..93f8abab56 100644 --- a/stdio-common/tst-vfprintf-width-i18n.c +++ b/stdio-common/tst-vfprintf-width-i18n.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <support/support.h> #include <support/check.h> +#include <libc-diag.h> static int do_test (void) @@ -48,6 +49,9 @@ do_test (void) TEST_COMPARE_STRING (buf, " INR12,345.67"); /* Translated. */ + /* clang does not know about the GNU extension 'I'. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (14, "-Wformat-invalid-specifier"); TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16); TEST_COMPARE_STRING (buf, " १२३४५"); TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 26); @@ -58,6 +62,7 @@ do_test (void) TEST_COMPARE_STRING (buf, " १२,३४५"); TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 26); TEST_COMPARE_STRING (buf, " १२,३४५.६७"); + DIAG_POP_NEEDS_COMMENT_CLANG; xsetlocale (LC_ALL, "ps_AF.UTF-8"); @@ -78,6 +83,8 @@ do_test (void) TEST_COMPARE_STRING (buf, " 12٬346 AFN"); /* Counts bytes. */ /* Translated. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (14, "-Wformat-invalid-specifier"); TEST_COMPARE (sprintf (buf, "%I11d", 12345), 11); TEST_COMPARE_STRING (buf, " ١٢٣۴٥"); TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 20); @@ -88,6 +95,7 @@ do_test (void) TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥"); TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 21); TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥٫٦٧"); + DIAG_POP_NEEDS_COMMENT_CLANG; return 0; }
From: Adhemerval Zanella <adhemerval.zanella@linaro.org> Clang issues the following warning: tst-vfprintf-width-i18n.c:51:34: error: invalid conversion specifier '1' [-Werror,-Wformat-invalid-specifier] TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16); ~~^ Since it does not how to handle %I. --- stdio-common/tst-vfprintf-width-i18n.c | 8 ++++++++ 1 file changed, 8 insertions(+)