On 05/20/2015 02:15 AM, Manuel López-Ibáñez wrote:
This is a new version of the patch submitted here:
https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00663.html
but handling (some) escape sequences.
I could not figure out a way to re-use the code from libcpp for this,
thus I implemented a simple function that given a string and offset in
bytes, it computes the visual column corresponding to that offset. The
function is very conservative: As soon as something unknown or
inconsistent is detected, it returns zero, thus preserving the current
behavior. This also preserves the current behavior for
non-concatenated tokens.
Bootstrapped and regression tested on x86_64-linux-gnu.
OK?
gcc/testsuite/ChangeLog:
2015-05-20 Manuel López-Ibáñez <m...@gcc.gnu.org>
PR c/52952
* gcc.dg/redecl-4.c: Update column numbers.
* gcc.dg/format/bitfld-1.c: Likewise.
* gcc.dg/format/attr-2.c: Likewise.
* gcc.dg/format/attr-6.c: Likewise.
* gcc.dg/format/attr-7.c (baz): 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. Add tests for column
locations within strings with embedded escape sequences.
gcc/c-family/ChangeLog:
2015-05-20 Manuel López-Ibáñez <m...@gcc.gnu.org>
PR c/52952
* c-format.c (location_column_from_byte_offset): New.
(location_from_offset): New.
(struct format_wanted_type): Add offset_loc field.
(check_format_info): Move handling of location for extra arguments
closer to the point of warning.
(check_format_arg): Set offset_is_invalid.
(check_format_info_main): Pass the result of location_from_offset
to warning_at.
(format_type_warning): Pass the result of location_from_offset
to warning_at.
So if I'm understanding the situation correctly, with this new version
behaviour for non-concatenated tokens is preserved which was the only
behaviour regression in the prior patch, right?
Thus, this version of the patch is strictly an improvement (points to
the issue within the format string rather than to the start of the
string). Right?
I don't particularly like file scoped "offset_is_invalid" variable. It
appears that it's only set within check_format_arg, but it's used from a
variety of other locations via location_from_offset. Given the current
structure of the code, alternatives would be even uglier.
Ok for the trunk.
Thanks,
Jeff