stdio: Suppress clang warnings for tst-unlockedio.c

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>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
Adhemerval Zanella 2022-03-24 16:03:16 -03:00 committed by H.J. Lu
parent cdcd551d82
commit 69c181f2b3

View File

@ -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