summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-18 14:31:50 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-18 14:31:50 +0000
commit15274a5afa59d6b892f2bc808aa0817b60990c94 (patch)
treea156c2a6ddb21fc39e98b05a696c4458d18b216e
parentd47a5ab185811d06aab4e614d6b9cca636aedb1a (diff)
downloadppe42-gcc-15274a5afa59d6b892f2bc808aa0817b60990c94.tar.gz
ppe42-gcc-15274a5afa59d6b892f2bc808aa0817b60990c94.zip
2005-02-18 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/20030 * fold-const.c (fold_indirect_ref_1): Use the correct index for zero access, the lower bound of the array type if it exists. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95226 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c15
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 61ea0ad332c..97c9e90017c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-18 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR middle-end/20030
+ * fold-const.c (fold_indirect_ref_1): Use the correct index for zero access,
+ the lower bound of the array type if it exists.
+
2005-02-18 Alexandre Oliva <aoliva@redhat.com>
PR c++/20008
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 27e16ae95cf..a04c0617724 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -11258,15 +11258,26 @@ fold_indirect_ref_1 (tree t)
/* *(foo *)&fooarray => fooarray[0] */
else if (TREE_CODE (optype) == ARRAY_TYPE
&& lang_hooks.types_compatible_p (type, TREE_TYPE (optype)))
- return build4 (ARRAY_REF, type, op, size_zero_node, NULL_TREE, NULL_TREE);
+ {
+ tree type_domain = TYPE_DOMAIN (optype);
+ tree min_val = size_zero_node;
+ if (type_domain && TYPE_MIN_VALUE (type_domain))
+ min_val = TYPE_MIN_VALUE (type_domain);
+ return build4 (ARRAY_REF, type, op, min_val, NULL_TREE, NULL_TREE);
+ }
}
/* *(foo *)fooarrptr => (*fooarrptr)[0] */
if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
&& lang_hooks.types_compatible_p (type, TREE_TYPE (TREE_TYPE (subtype))))
{
+ tree type_domain;
+ tree min_val = size_zero_node;
sub = build_fold_indirect_ref (sub);
- return build4 (ARRAY_REF, type, sub, size_zero_node, NULL_TREE, NULL_TREE);
+ type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
+ if (type_domain && TYPE_MIN_VALUE (type_domain))
+ min_val = TYPE_MIN_VALUE (type_domain);
+ return build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE);
}
return NULL_TREE;
OpenPOWER on IntegriCloud