S390: Get rid of format warning in bug-vfprintf-nargs.c
Commit Message
Hi,
on 31bit s390 i get the following warning/error:
gcc bug-vfprintf-nargs.c -c ...
bug-vfprintf-nargs.c: In function ‘do_test’:
bug-vfprintf-nargs.c:68:7: error: format ‘%d’ expects argument of type
‘int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]
sprintf (buf, "%%1$d %%%" PRIdPTR "$d", UINT32_MAX / sizeof (int));
This patch suppresses the format warning with the diagnostic control
pragmas.
Thus the behaviour of this testcase isn´t changed.
Ok to commit?
Bye
Stefan
---
2014-12-12 Stefan Liebler <stli@linux.vnet.ibm.com>
* stdio-common/bug-vfprintf-nargs.c (do_test):
Disable format warning with diagnostic control pragma.
Comments
I think you can just cast the value to intptr_t.
@@ -24,6 +24,7 @@
#include <inttypes.h>
#include <string.h>
#include <signal.h>
+#include <libc-internal.h>
static int
format_failed (const char *fmt, const char *expected)
@@ -65,7 +66,13 @@ do_test (void)
test this on 32-bit systems. */
if (sizeof (long int) == 4)
{
+ /* On S390 31bit, gcc emits the warning:
+ format ‘%d’ expects argument of type ‘int’,
+ but argument 3 has type ‘long unsigned int’. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (5, "-Wformat");
sprintf (buf, "%%1$d %%%" PRIdPTR "$d", UINT32_MAX / sizeof (int));
+ DIAG_POP_NEEDS_COMMENT;
if (format_failed (buf, "1 %$d") != 0)
rc = 1;
}