summaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2019-11-05 16:20:44 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2019-11-05 09:20:44 -0700
commit361d4a9eb6b397f3401b7693ee9fbc032e95a0f0 (patch)
treed0efeac99cf67e900fd19921105e9211998dbe51 /gcc/tree-sra.c
parent02bf7e6fa219f939b3225c54fbe8bab2133b1aeb (diff)
PR middle-end/92341 - missing -Warray-bounds indexing past the end of a compound literal
PR middle-end/92341 - missing -Warray-bounds indexing past the end of a compound literal PR middle-end/82612 - missing -Warray-bounds on a non-zero offset from the address of a non-array object gcc/testsuite/ChangeLog: PR middle-end/92341 PR middle-end/82612 * g++.dg/warn/Warray-bounds-4.C: Adjust text of expected warning. * gcc.dg/Warray-bounds-53.c: New test. * gcc.dg/Warray-bounds-54.c: New test. gcc/ChangeLog: PR middle-end/92341 PR middle-end/82612 * tree-sra.c (get_access_for_expr): Fail for out-of-bounds offsets. * tree-vrp.c (vrp_prop::check_array_ref): Correct index and text of message printed in a warning for empty arrays. (vrp_prop::check_mem_ref): Also handle function parameters and empty arrays. From-SVN: r277851
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 3f104238d93..44862690559 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -3068,6 +3068,13 @@ get_access_for_expr (tree expr)
|| !DECL_P (base))
return NULL;
+ if (tree basesize = DECL_SIZE (base))
+ {
+ poly_int64 sz = tree_to_poly_int64 (basesize);
+ if (offset < 0 || known_le (sz, offset))
+ return NULL;
+ }
+
if (!bitmap_bit_p (candidate_bitmap, DECL_UID (base)))
return NULL;