aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-02-25 13:20:25 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-02-25 13:20:25 +0000
commit798e2a8ed800a05e24f8969dc236bc4b7b2af163 (patch)
tree2ecd27e12a65a3a74e1a672c7bdc3223514e0105 /gcc/tree-vrp.c
parent9559fbacc6d7e9f07f96443baadf931758ab00f3 (diff)
downloadgcc-798e2a8ed800a05e24f8969dc236bc4b7b2af163.zip
gcc-798e2a8ed800a05e24f8969dc236bc4b7b2af163.tar.gz
gcc-798e2a8ed800a05e24f8969dc236bc4b7b2af163.tar.bz2
re PR tree-optimization/48795 (-Warray-bounds false positive)
2016-02-25 Richard Biener <rguenther@suse.de> PR tree-optimization/48795 * tree-vrp.c (check_array_ref): Use array_at_struct_end_p. * gcc.dg/Warray-bounds-18.c: New testcase. From-SVN: r233714
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 0ce7f1f..a11635d 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -6450,7 +6450,6 @@ check_array_ref (location_t location, tree ref, bool ignore_off_by_one)
value_range *vr = NULL;
tree low_sub, up_sub;
tree low_bound, up_bound, up_bound_p1;
- tree base;
if (TREE_NO_WARNING (ref))
return;
@@ -6465,27 +6464,9 @@ check_array_ref (location_t location, tree ref, bool ignore_off_by_one)
/* Accesses to trailing arrays via pointers may access storage
beyond the types array bounds. */
- base = get_base_address (ref);
- if ((warn_array_bounds < 2)
- && base && TREE_CODE (base) == MEM_REF)
- {
- tree cref, next = NULL_TREE;
-
- if (TREE_CODE (TREE_OPERAND (ref, 0)) != COMPONENT_REF)
- return;
-
- cref = TREE_OPERAND (ref, 0);
- if (TREE_CODE (TREE_TYPE (TREE_OPERAND (cref, 0))) == RECORD_TYPE)
- for (next = DECL_CHAIN (TREE_OPERAND (cref, 1));
- next && TREE_CODE (next) != FIELD_DECL;
- next = DECL_CHAIN (next))
- ;
-
- /* If this is the last field in a struct type or a field in a
- union type do not warn. */
- if (!next)
- return;
- }
+ if (warn_array_bounds < 2
+ && array_at_struct_end_p (ref))
+ return;
low_bound = array_ref_low_bound (ref);
up_bound_p1 = int_const_binop (PLUS_EXPR, up_bound,