Message ID | 20241222000509.2205895-26-hjl.tools@gmail.com |
---|---|
State | New |
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> > > Suppress the following -Wgnu-folding-constant and -Wliteral-conversion > warnings from Clang: > > tst-unlockedio.c:35:12: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant] > 35 | char buf[strlen (blah) + 1]; > | ^~~~~~~~~~~~~~~~~ > > tst-unlockedio.c:63:36: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from -0 to 0 > [-Werror,-Wliteral-conversion] > || fwrite_unlocked (blah, 0, -0.0, fp) != 0 > ~~~~~~~~~~~~~~~ ^~~~ > tst-unlockedio.c:61:33: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 > [-Werror,-Wliteral-conversion] > || fwrite_unlocked (--cp, 0.25, 16, fp) != 0 > ~~~~~~~~~~~~~~~ ^~~~ > tst-unlockedio.c:59:37: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 > [-Werror,-Wliteral-conversion] > || fwrite_unlocked (cp++, 16, 0.25, fp) != 0 > ~~~~~~~~~~~~~~~ ^~~~ > tst-unlockedio.c:116:34: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from -0 to 0 > [-Werror,-Wliteral-conversion] > || fread_unlocked (buf, 0, -0.0, fp) != 0 > ~~~~~~~~~~~~~~ ^~~~ > tst-unlockedio.c:114:32: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 > [-Werror,-Wliteral-conversion] > || fread_unlocked (--wp, 0.25, 16, fp) != 0 > ~~~~~~~~~~~~~~ ^~~~ > tst-unlockedio.c:112:36: error: implicit conversion from 'double' to > 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 > [-Werror,-Wliteral-conversion] > || fread_unlocked (wp++, 16, 0.25, fp) != 0 > ~~~~~~~~~~~~~~ ^~~~ > > Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> > --- > stdio-common/tst-unlockedio.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c > index 8ff6b074b0..7f156b3c11 100644 > --- a/stdio-common/tst-unlockedio.c > +++ b/stdio-common/tst-unlockedio.c > @@ -32,7 +32,10 @@ static int > do_test (void) > { > const char blah[] = "BLAH"; > + DIAG_PUSH_NEEDS_COMMENT_CLANG; > + DIAG_IGNORE_NEEDS_COMMENT_CLANG (3.4, "-Wgnu-folding-constant"); > char buf[strlen (blah) + 1]; > + DIAG_POP_NEEDS_COMMENT_CLANG; > FILE *fp, *f; > const char *cp; > char *wp; > @@ -51,6 +54,9 @@ do_test (void) > fread_unlocked below as well. */ > DIAG_PUSH_NEEDS_COMMENT; > DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero"); > + /* clang warns about the implicit conversion from double to size_t, > + which is required by this tests. */ > + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wliteral-conversion"); > if (ftello (fp) != 0 > || fwrite_unlocked (blah, blah - blah, strlen (blah), f++) != 0 > || f != fp + 1 > @@ -104,6 +110,7 @@ do_test (void) > /* See explanation above. */ > DIAG_PUSH_NEEDS_COMMENT; > DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero"); > + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wliteral-conversion"); > if (ftello (fp) != 0 > || fread_unlocked (buf, buf - buf, strlen (blah), f++) != 0 > || f != fp + 1 Reviewed-by: Sam James <sam@gentoo.org>
diff --git a/stdio-common/tst-unlockedio.c b/stdio-common/tst-unlockedio.c index 8ff6b074b0..7f156b3c11 100644 --- a/stdio-common/tst-unlockedio.c +++ b/stdio-common/tst-unlockedio.c @@ -32,7 +32,10 @@ static int do_test (void) { const char blah[] = "BLAH"; + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (3.4, "-Wgnu-folding-constant"); char buf[strlen (blah) + 1]; + DIAG_POP_NEEDS_COMMENT_CLANG; FILE *fp, *f; const char *cp; char *wp; @@ -51,6 +54,9 @@ do_test (void) fread_unlocked below as well. */ DIAG_PUSH_NEEDS_COMMENT; DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero"); + /* clang warns about the implicit conversion from double to size_t, + which is required by this tests. */ + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wliteral-conversion"); if (ftello (fp) != 0 || fwrite_unlocked (blah, blah - blah, strlen (blah), f++) != 0 || f != fp + 1 @@ -104,6 +110,7 @@ do_test (void) /* See explanation above. */ DIAG_PUSH_NEEDS_COMMENT; DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdiv-by-zero"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wliteral-conversion"); if (ftello (fp) != 0 || fread_unlocked (buf, buf - buf, strlen (blah), f++) != 0 || f != fp + 1
From: Adhemerval Zanella <adhemerval.zanella@linaro.org> Suppress the following -Wgnu-folding-constant and -Wliteral-conversion warnings from Clang: tst-unlockedio.c:35:12: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant] 35 | char buf[strlen (blah) + 1]; | ^~~~~~~~~~~~~~~~~ tst-unlockedio.c:63:36: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from -0 to 0 [-Werror,-Wliteral-conversion] || fwrite_unlocked (blah, 0, -0.0, fp) != 0 ~~~~~~~~~~~~~~~ ^~~~ tst-unlockedio.c:61:33: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 [-Werror,-Wliteral-conversion] || fwrite_unlocked (--cp, 0.25, 16, fp) != 0 ~~~~~~~~~~~~~~~ ^~~~ tst-unlockedio.c:59:37: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 [-Werror,-Wliteral-conversion] || fwrite_unlocked (cp++, 16, 0.25, fp) != 0 ~~~~~~~~~~~~~~~ ^~~~ tst-unlockedio.c:116:34: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from -0 to 0 [-Werror,-Wliteral-conversion] || fread_unlocked (buf, 0, -0.0, fp) != 0 ~~~~~~~~~~~~~~ ^~~~ tst-unlockedio.c:114:32: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 [-Werror,-Wliteral-conversion] || fread_unlocked (--wp, 0.25, 16, fp) != 0 ~~~~~~~~~~~~~~ ^~~~ tst-unlockedio.c:112:36: error: implicit conversion from 'double' to 'size_t' (aka 'unsigned long') changes value from 0.25 to 0 [-Werror,-Wliteral-conversion] || fread_unlocked (wp++, 16, 0.25, fp) != 0 ~~~~~~~~~~~~~~ ^~~~ Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> --- stdio-common/tst-unlockedio.c | 7 +++++++ 1 file changed, 7 insertions(+)