Commit 36427b78 by Richard Kenner

(layout_type...

(layout_type, case ARRAY_TYPE): Compute length using MAX of length and
zero if sizetype signed and neither bound constant.

From-SVN: r9668
parent 74a35b2b
/* 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));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment