aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-09-23 15:04:32 -0600
committerMartin Sebor <msebor@redhat.com>2020-09-23 15:10:20 -0600
commit6edc8f5bfe7d9db8fb8bd37bb8086a69850c6c6d (patch)
treec64709a3a48fac8d149e61be1ff8144e8ff8025d /gcc/builtins.c
parente977dd5edbcc3a3b88c3bd7efa1026c845af7487 (diff)
downloadgcc-6edc8f5bfe7d9db8fb8bd37bb8086a69850c6c6d.zip
gcc-6edc8f5bfe7d9db8fb8bd37bb8086a69850c6c6d.tar.gz
gcc-6edc8f5bfe7d9db8fb8bd37bb8086a69850c6c6d.tar.bz2
Handle DECLs and EXPRESSIONs consistently (PR middle-end/97175).
gcc/ChangeLog: PR middle-end/97175 * builtins.c (maybe_warn_for_bound): Handle both DECLs and EXPRESSIONs in pad->dst.ref, same is pad->src.ref. gcc/testsuite/ChangeLog: PR middle-end/97175 * gcc.dg/Wstringop-overflow-44.c: New test.
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 45efc1c..cac842f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3480,8 +3480,14 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func,
if (warned)
{
if (pad && pad->dst.ref)
- inform (DECL_SOURCE_LOCATION (pad->dst.ref),
- "destination object declared here");
+ {
+ if (DECL_P (pad->dst.ref))
+ inform (DECL_SOURCE_LOCATION (pad->dst.ref),
+ "destination object declared here");
+ else if (EXPR_HAS_LOCATION (pad->dst.ref))
+ inform (EXPR_LOCATION (pad->dst.ref),
+ "destination object allocated here");
+ }
TREE_NO_WARNING (exp) = true;
}