This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] have -Wnonnull print inlining stack (PR 83369)
- From: Martin Sebor <msebor at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 11 Dec 2017 09:51:40 -0700
- Subject: [PATCH] have -Wnonnull print inlining stack (PR 83369)
- Authentication-results: sourceware.org; auth=none
Bug 83369 - Missing diagnostics during inlining, notes that when
-Wnonnull is issued for an inlined call to a built-in function,
GCC doesn't print the inlining stack, making it hard to debug
where the problem comes from.
When the -Wnonnull warning was introduced into the middle-end
the diagnostic machinery provided no way to print the inlining
stack (analogous to %K for trees). Since then GCC has gained
support for the %G directive which does just that. The attached
patch makes use of the directive to print the inlining context
for -Wnonnull.
The patch doesn't include a test because the DejaGnu framework
provides no mechanism to validate this part of GCC output (see
also bug 83336).
Tested on x86_64-linux with no regressions.
Martin
PR c/83369 - Missing diagnostics during inlining
gcc/ChangeLog:
PR c/83369
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Use %G to print
inlining context.
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 3acddf9..8a405fc 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -3457,8 +3457,8 @@ pass_post_ipa_warn::execute (function *fun)
location_t loc = gimple_location (stmt);
if (warning_at (loc, OPT_Wnonnull,
- "argument %u null where non-null "
- "expected", i + 1))
+ "%Gargument %u null where non-null "
+ "expected", as_a <gcall *>(stmt), i + 1))
{
tree fndecl = gimple_call_fndecl (stmt);
if (fndecl && DECL_IS_BUILTIN (fndecl))