aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-live.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-01-19 15:10:30 -0700
committerMartin Sebor <msebor@redhat.com>2021-01-19 15:10:30 -0700
commit9693e255ee2536c6823640eba5d0163c2b401161 (patch)
tree5f5735deb16a463d71fd69e8fcffe5b131aec478 /gcc/tree-ssa-live.c
parent29853c653245c37ed31b6abcc9799b534372e938 (diff)
downloadgcc-9693e255ee2536c6823640eba5d0163c2b401161.zip
gcc-9693e255ee2536c6823640eba5d0163c2b401161.tar.gz
gcc-9693e255ee2536c6823640eba5d0163c2b401161.tar.bz2
PR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls to system headers
gcc/ChangeLog: PR middle-end/98664 * tree-ssa-live.c (remove_unused_scope_block_p): Keep scopes for all functions, even if they're not declared artificial or inline. * tree.c (tree_inlined_location): Use macro expansion location only if scope traversal fails to expose one. gcc/testsuite/ChangeLog: PR middle-end/98664 * gcc.dg/Wvla-larger-than-4.c: Adjust expected output. * gcc.dg/plugin/diagnostic-test-inlining-3.c: Same. * g++.dg/warn/Wfree-nonheap-object-5.C: New test. * gcc.dg/Wfree-nonheap-object-4.c: New test.
Diffstat (limited to 'gcc/tree-ssa-live.c')
-rw-r--r--gcc/tree-ssa-live.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index 02a7a56..a2aab25 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -555,20 +555,17 @@ remove_unused_scope_block_p (tree scope, bool in_ctor_dtor_block)
;
/* When not generating debug info we can eliminate info on unused
variables. */
- else if (!flag_auto_profile && debug_info_level == DINFO_LEVEL_NONE
+ else if (!flag_auto_profile
+ && debug_info_level == DINFO_LEVEL_NONE
&& !optinfo_wants_inlining_info_p ())
{
- /* Even for -g0 don't prune outer scopes from artificial
- functions, otherwise diagnostics using tree_nonartificial_location
- will not be emitted properly. */
+ /* Even for -g0 don't prune outer scopes from inlined functions,
+ otherwise late diagnostics from such functions will not be
+ emitted or suppressed properly. */
if (inlined_function_outer_scope_p (scope))
{
- tree ao = BLOCK_ORIGIN (scope);
- if (ao
- && TREE_CODE (ao) == FUNCTION_DECL
- && DECL_DECLARED_INLINE_P (ao)
- && lookup_attribute ("artificial", DECL_ATTRIBUTES (ao)))
- unused = false;
+ gcc_assert (TREE_CODE (BLOCK_ORIGIN (scope)) == FUNCTION_DECL);
+ unused = false;
}
}
else if (BLOCK_VARS (scope) || BLOCK_NUM_NONLOCALIZED_VARS (scope))