aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.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/stor-layout.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/stor-layout.c')
-rw-r--r--gcc/stor-layout.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 043ad28..b44a411 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -783,6 +783,7 @@ layout_type (type)
tree ub = TYPE_MAX_VALUE (index);
tree lb = TYPE_MIN_VALUE (index);
tree length;
+ tree element_size;
/* If UB is max (lb - 1, x), remove the MAX_EXPR since the
test for negative below covers it. */
@@ -815,8 +816,19 @@ layout_type (type)
&& TREE_CODE (TYPE_MAX_VALUE (index)) != INTEGER_CST)
length = size_binop (MAX_EXPR, length, size_zero_node);
- TYPE_SIZE (type) = size_binop (MULT_EXPR, TYPE_SIZE (element),
- length);
+ /* Special handling for arrays of bits (for Chill). */
+ element_size = TYPE_SIZE (element);
+ if (TYPE_PACKED (type) && INTEGRAL_TYPE_P (element))
+ {
+ HOST_WIDE_INT maxvalue, minvalue;
+ maxvalue = TREE_INT_CST_LOW (TYPE_MAX_VALUE (element));
+ minvalue = TREE_INT_CST_LOW (TYPE_MIN_VALUE (element));
+ if (maxvalue - minvalue == 1
+ && (maxvalue == 1 || maxvalue == 0))
+ element_size = integer_one_node;
+ }
+
+ TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size, length);
/* If we know the size of the element, calculate the total
size directly, rather than do some division thing below.