diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2006-12-07 14:39:37 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2006-12-07 14:39:37 +0000 |
commit | a3de5951ce039bb9258997655159ce062ba07265 (patch) | |
tree | e1a24f3812cec9e295f4d039e3567910ce12e686 | |
parent | 5eab7e7af0b310eb56474a8978b57387aafc0036 (diff) | |
download | gcc-a3de5951ce039bb9258997655159ce062ba07265.zip gcc-a3de5951ce039bb9258997655159ce062ba07265.tar.gz gcc-a3de5951ce039bb9258997655159ce062ba07265.tar.bz2 |
expr.c (string_constant): Account for non-zero lower bound arrays.
2006-12-07 Andrew Macleod <amacleod@redhat.com>
* expr.c (string_constant): Account for non-zero lower bound arrays.
From-SVN: r119623
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/expr.c | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0926c1d..3c98eb1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2006-12-07 Andrew Macleod <amacleod@redhat.com> + + * expr.c (string_constant): Account for non-zero lower bound arrays. + 2006-12-07 Richard Guenther <rguenther@suse.de> * builtins.c (expand_builtin_pow): Adjust predicates for @@ -8923,7 +8923,7 @@ is_aligning_offset (tree offset, tree exp) tree string_constant (tree arg, tree *ptr_offset) { - tree array, offset; + tree array, offset, lower_bound; STRIP_NOPS (arg); if (TREE_CODE (arg) == ADDR_EXPR) @@ -8945,6 +8945,20 @@ string_constant (tree arg, tree *ptr_offset) if (TREE_CODE (array) != STRING_CST && TREE_CODE (array) != VAR_DECL) return 0; + + /* Check if the array has a non-zero lower bound. */ + lower_bound = array_ref_low_bound (TREE_OPERAND (arg, 0)); + if (!integer_zerop (lower_bound)) + { + /* If the offset and base aren't both constants, return 0. */ + if (TREE_CODE (lower_bound) != INTEGER_CST) + return 0; + if (TREE_CODE (offset) != INTEGER_CST) + return 0; + /* Adjust offset by the lower bound. */ + offset = size_diffop (fold_convert (sizetype, offset), + fold_convert (sizetype, lower_bound)); + } } else return 0; |