On 01/03/2018 04:47 PM, Jakub Jelinek wrote:
On Tue, Jan 02, 2018 at 04:40:50PM -0700, Jeff Law wrote:
Attached is the patch with the casts removed (still bootstrapping).
Martin
gcc-printf-lli.diff
gcc/ChangeLog:
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Use
offset_int::from instead of wide_int::to_shwi.
(maybe_diag_overlap): Remove assertion.
Use HOST_WIDE_INT_PRINT_DEC instead of %lli.
* gimple-ssa-sprintf.c (format_directive): Same.
(parse_directive): Same.
(sprintf_dom_walker::compute_format_length): Same.
(try_substitute_return_value): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/Wrestrict-3.c: New test.
OK.
This broke bootstrap on i686-linux, dir.len is size_t, which isn't always
appropriate for HOST_WIDE_INT_PRINT_DEC format.
Fixed thusly, committed to trunk as obvious after i686-linux bootstrap
went past the previous failure point.
Thanks.
This is an example where having a solution for bug 78014 would
be helpful. I.e., a -Wformat checker to help enforce the use
of %zu instead of %u or %lu (or an explicit cast from size_t)
even on targets size_t is unsigned or unsigned long, respectively.
Martin
2018-01-04 Jakub Jelinek <ja...@redhat.com>
* gimple-ssa-sprintf.c (parse_directive): Cast second dir.len to uhwi.
--- gcc/gimple-ssa-sprintf.c.jj 2018-01-03 22:24:36.000000000 +0100
+++ gcc/gimple-ssa-sprintf.c 2018-01-04 00:15:55.950179583 +0100
@@ -3040,7 +3040,7 @@ parse_directive (sprintf_dom_walker::cal
"length = " HOST_WIDE_INT_PRINT_UNSIGNED "\n",
dir.dirno,
(unsigned HOST_WIDE_INT)(size_t)(dir.beg - info.fmtstr),
- (int)dir.len, dir.beg, dir.len);
+ (int)dir.len, dir.beg, (unsigned HOST_WIDE_INT) dir.len);
}
return len - !*str;
Jakub