diff options
author | simonb <simonb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-01 19:03:32 +0000 |
---|---|---|
committer | simonb <simonb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-01 19:03:32 +0000 |
commit | 98cb064a88338684234aeff8d4dca8b4768e6b35 (patch) | |
tree | 9ed540dc4bc280eaffa691609aa5d92b79a62090 /gcc/tree-vrp.c | |
parent | 49698f189da3d0b50c33959fe9f59be8fc7d061e (diff) | |
download | gcc-98cb064a88338684234aeff8d4dca8b4768e6b35.tar.gz |
* c-common.h (warn_array_subscript_range): New function.
* c-common.c (warn_array_subscript_range): Ditto.
* tree-vrp.c (check_array_ref): Corrected code to agree with
comment, ignoring only arrays of size 0 or size 1.
* c-typeck.c (build_array_ref): Call warn_array_subscript_range.
* testsuite/gcc.dg/Warray-bounds.c: Updated for frontend warnings,
additional tests for arrays of size 0 and size 1.
* testsuite/g++.dg/warn/Warray-bounds.c: Ditto.
* testsuite/gcc.dg/Warray-bounds-noopt.c: New testcase.
* testsuite/g++.dg/warn/Warray-bounds-noopt.c: Ditto.
* typeck.c (build_array_ref): Call warn_array_subscript_range.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134865 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 4b409e46aaf..61031996185 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4645,8 +4645,8 @@ check_array_ref (tree ref, location_t* locus, bool ignore_off_by_one) && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (ref))) == NULL_TREE) /* Accesses after the end of arrays of size 0 (gcc extension) and 1 are likely intentional ("struct - hack"). */ - || compare_tree_int (up_bound, 1) <= 0) + hack"). Note that up_bound is array dimension - 1. */ + || compare_tree_int (up_bound, 1) < 0) return; low_bound = array_ref_low_bound (ref); |