This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] Support string locations for C++ in -Wformat (PR c++/56856)


On Thu, Oct 4, 2018 at 10:12 AM David Malcolm <dmalcolm@redhat.com> wrote:
>
> -Wformat in the C++ FE doesn't work as well as it could:
> (a) it doesn't report precise locations within the string literal, and
> (b) it doesn't underline arguments for those arguments !CAN_HAVE_LOCATION_P,
> despite having location wrapper nodes.
>
> For example:
>
>   Wformat-ranges.C:32:10: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'int' [-Wformat=]
>   32 |   printf("hello %s", 42);
>      |          ^~~~~~~~~~
>
> (a) is due to not wiring up the langhook for extracting substring
>     locations.
>
>     This patch uses the one in c-family; it also fixes string literal
>     parsing so that it records string concatenations (needed for
>     extracting substring locations from concatenated strings).
>
> (b) is due to the call to maybe_constant_value here:
>        fargs[j] = maybe_constant_value (argarray[j]);
>     within build_over_call.

Maybe we should remove that in favor of fold_for_warn in
check_function_arguments.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]