diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-05-12 22:31:57 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-05-12 22:31:57 +0000 |
commit | a596ab500a5b95848346ccdb7242add5b49c9447 (patch) | |
tree | aeb86d521519ea147ee57f10d508fccbc5869220 /gcc/stor-layout.c | |
parent | fb9989d7feea53de2034e0bf84bd3c6e1a4603f8 (diff) | |
download | gcc-a596ab500a5b95848346ccdb7242add5b49c9447.tar.gz |
(layout_type, case ARRAY_TYPE): Compute length using MAX of length and
zero if sizetype signed and neither bound constant.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@9668 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 669a1de2523..e37c8dfdacf 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1,5 +1,5 @@ /* C-compiler utilities for types and variables storage layout - Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1987, 88, 92, 93, 94, 1995 Free Software Foundation, Inc. This file is part of GNU CC. @@ -740,6 +740,15 @@ layout_type (type) size_binop (MINUS_EXPR, TYPE_MAX_VALUE (index), TYPE_MIN_VALUE (index))); + /* If neither bound is a constant and sizetype is signed, make + sure the size is never negative. We should really do this + if *either* bound is non-constant, but this is the best + compromise between C and Ada. */ + if (! TREE_UNSIGNED (sizetype) + && TREE_CODE (TYPE_MIN_VALUE (index)) != INTEGER_CST + && TREE_CODE (TYPE_MAX_VALUE (index)) != INTEGER_CST) + length = size_binop (MAX_EXPR, length, size_zero_node); + TYPE_SIZE (type) = size_binop (MULT_EXPR, length, TYPE_SIZE (element)); } |