I should have pointed out that this is based on a preliminary patch by Steven attached to PR 52952. I will update the Changelog to reflect this when committing.
Cheers, Manuel. On 15 August 2014 15:51, Manuel López-Ibáñez <lopeziba...@gmail.com> wrote: > Hi, > > This patch moves the location of various Wformat warnings from > pointing to the first character of the function name (such as printf) > to the actual format string. This is specially useful when you have > something like > > printf (cond ? "format 1" : "format 2"); > > It also moves (some) of the warnings about too many arguments to the > first argument that is unused. Since the format string and/or the > arguments might not be expressions or strings, this doesn't always > work and then we are back to the status-quo. > > This is anyway a first step. I have some patches to point within the > format string for some cases. This is why I added column markers to > testcases even if we don't actually improve the location: it will > help us to identify testcases that need updating as the location info > improves. > > Unfortunately, reaching the level of Clang seems well beyond the time > I can dedicate to this, so any help would be appreciated. > > OK for trunk? > > > gcc/c-family/ChangeLog: > > 2014-08-15 Manuel López-Ibáñez <manu.gnu.org> > > PR c/52952 > * c-format.c: Add extra_arg_loc and format_string_loc to struct > format_check_results. > (check_function_format): Use true and add comment for boolean > argument. > (finish_dollar_format_checking): Use explicit location when warning. > (check_format_info): Likewise. > (check_format_arg): Set extra_arg_loc and format_string_loc. > (check_format_info_main): Use explicit location when warning. > (check_format_types): Pass explicit location. > (format_type_warning): Likewise. > > gcc/testsuite/ChangeLog: > > 2014-08-15 Manuel López-Ibáñez <manu.gnu.org> > > PR c/52952 > * gcc.dg/redecl-4.c: Add column markers. > * gcc.dg/format/bitfld-1.c: Likewise. > * gcc.dg/format/attr-2.c: Likewise. > * gcc.dg/format/attr-6.c: Likewise. > * gcc.dg/format/array-1.c: Likewise. > * gcc.dg/format/attr-7.c: Likewise. > * gcc.dg/format/asm_fprintf-1.c: Likewise. > * gcc.dg/format/attr-4.c: Likewise. > * gcc.dg/format/branch-1.c: Likewise. > * gcc.dg/format/c90-printf-1.c: Likewise.