aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorDave Brolley <brolley@cygnus.com>1998-07-27 14:37:00 +0000
committerDave Brolley <brolley@gcc.gnu.org>1998-07-27 10:37:00 -0400
commit74a4fbfcc81a5bb93e4a609beeb214e53f6a7bc9 (patch)
treeffa2167aaf158c2fc77376592c3f34d3d595c5ee /gcc/expr.c
parent4944f54f41c6f1c3bebc247007a5179f5e19a81a (diff)
downloadgcc-74a4fbfcc81a5bb93e4a609beeb214e53f6a7bc9.zip
gcc-74a4fbfcc81a5bb93e4a609beeb214e53f6a7bc9.tar.gz
gcc-74a4fbfcc81a5bb93e4a609beeb214e53f6a7bc9.tar.bz2
stor-layout.c (layout_type): Handle arrays of bits, for Chill.
Mon Jul 27 17:18:52 1998 Dave Brolley <brolley@cygnus.com> * stor-layout.c (layout_type): Handle arrays of bits, for Chill. * expr.c (get_inner_reference): Handle zero-based, unsigned, array index conversion. From-SVN: r21416
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index fd43689..208db5c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4546,8 +4546,20 @@ get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode,
index_type = TREE_TYPE (index);
}
+ /* Optimize the special-case of a zero lower bound.
+
+ We convert the low_bound to sizetype to avoid some problems
+ with constant folding. (E.g. suppose the lower bound is 1,
+ and its mode is QI. Without the conversion, (ARRAY
+ +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
+ +INDEX), which becomes (ARRAY+255+INDEX). Oops!)
+
+ But sizetype isn't quite right either (especially if
+ the lowbound is negative). FIXME */
+
if (! integer_zerop (low_bound))
- index = fold (build (MINUS_EXPR, index_type, index, low_bound));
+ index = fold (build (MINUS_EXPR, index_type, index,
+ convert (sizetype, low_bound)));
if (TREE_CODE (index) == INTEGER_CST)
{