aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.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.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.c')
-rw-r--r--gcc/tree.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index a25c71f..061fe43 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -12638,10 +12638,13 @@ tree_inlined_location (tree exp, bool system_header /* = true */)
}
if (loc == UNKNOWN_LOCATION)
- loc = EXPR_LOCATION (exp);
-
- if (system_header)
- return expansion_point_location_if_in_system_header (loc);
+ {
+ loc = EXPR_LOCATION (exp);
+ if (system_header)
+ /* Only consider macro expansion when the block traversal failed
+ to find a location. Otherwise it's not relevant. */
+ return expansion_point_location_if_in_system_header (loc);
+ }
return loc;
}