This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Provide inlining context in strict-overflow warnings
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 May 2014 11:56:22 +0200
- Subject: Re: [PATCH] Provide inlining context in strict-overflow warnings
- Authentication-results: sourceware.org; auth=none
- References: <5372720C dot 20404 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, May 13, 2014 at 09:27:08PM +0200, Florian Weimer wrote:
> Patterns that trigger the optimization and warning can form after
> inlining, and it can be rather difficult to figure out what exactly
> is causing the warning. The inlining context at least provides
> additional hints, enabling developers to substitute the arguments
> and discover what, precisely, is happening.
>
> More context is provided with -g than without, but I think this is
> acceptable.
>
> I bootstrapped and tested the attached patch on
> x86_64-redhat-linux-gnu, with no new regressions.
This looks wrong. If you want to print inline context, you just should
use %K%s and pass a tree with the right EXPR_LOCATION and TREE_BLOCK.
So perhaps:
if (stmt == NULL)
warning_at (input_location, OPT_Wstrict_overflow, "%s", warnmsg);
else
warning_at (gimple_location (stmt), OPT_Wstrict_overflow, "%K%s",
build_empty_stmt (gimple_location (stmt)), warnmsg);
(or add something similar to %K that will take location_t or change
%K to take location_t instead of tree now that we have both a block and
locus in location_t.
Note, your patch would happily crash if stmt is NULL.
Jakub