From 5e9abf2ce4a4e1e380a1da8016eac24b22973dfd Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 5 Nov 2008 17:06:38 +0100 Subject: re PR middle-end/37861 (Bogus array bounds warning) 2008-11-05 Martin Jambor PR middle-end/37861 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't turn pointer arithmetics into array_ref if the array is accessed through an indirect_ref. * testsuite/gcc.dg/Warray-bounds-5.c: New file. * testsuite/gcc.dg/Warray-bounds-6.c: New file. From-SVN: r141613 --- gcc/tree-ssa-forwprop.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/tree-ssa-forwprop.c') diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index a04e7ca..5626b10 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -802,6 +802,9 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, array_ref = TREE_OPERAND (def_rhs, 0); if (TREE_CODE (array_ref) != ARRAY_REF || TREE_CODE (TREE_TYPE (TREE_OPERAND (array_ref, 0))) != ARRAY_TYPE + /* Avoid accessing hidden multidimensional arrays in this way or VRP + might give out bogus warnings (see PR 37861) */ + || TREE_CODE (TREE_OPERAND (array_ref, 0)) == INDIRECT_REF || !integer_zerop (TREE_OPERAND (array_ref, 1))) return false; -- cgit v1.1