aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-02-28 17:53:50 -0500
committerJason Merrill <jason@gcc.gnu.org>2003-02-28 17:53:50 -0500
commit3695c25fd69298585a64cb682a84027ccbd4b724 (patch)
treed4062331b69694bd3a7bf9f269219dca8daa4de9 /gcc
parent0ea05c0da385f546437e32c43512dc2565c504eb (diff)
downloadgcc-3695c25fd69298585a64cb682a84027ccbd4b724.zip
gcc-3695c25fd69298585a64cb682a84027ccbd4b724.tar.gz
gcc-3695c25fd69298585a64cb682a84027ccbd4b724.tar.bz2
stor-layout.c (variable_size): Leave a minus 1 outside the SAVE_EXPR.
* stor-layout.c (variable_size): Leave a minus 1 outside the SAVE_EXPR. From-SVN: r63585
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/stor-layout.c20
2 files changed, 17 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5fc0c2e..f1407b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-02-28 Jason Merrill <jason@redhat.com>
+
+ * stor-layout.c (variable_size): Leave a "minus 1" outside the
+ SAVE_EXPR.
+
2003-02-28 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/power4.md: Add compare bypass.
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 8fd70ad..6caaf5f 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -157,6 +157,8 @@ tree
variable_size (size)
tree size;
{
+ tree save;
+
/* If the language-processor is to take responsibility for variable-sized
items (e.g., languages which have elaboration procedures like Ada),
just return SIZE unchanged. Likewise for self-referential sizes and
@@ -166,7 +168,12 @@ variable_size (size)
|| contains_placeholder_p (size))
return size;
- size = save_expr (size);
+ if (TREE_CODE (size) == MINUS_EXPR && integer_onep (TREE_OPERAND (size, 1)))
+ /* If this is the upper bound of a C array, leave the minus 1 outside
+ the SAVE_EXPR so it can be folded away. */
+ TREE_OPERAND (size, 0) = save = save_expr (TREE_OPERAND (size, 0));
+ else
+ size = save = save_expr (size);
/* If an array with a variable number of elements is declared, and
the elements require destruction, we will emit a cleanup for the
@@ -176,8 +183,8 @@ variable_size (size)
`unsaved', i.e., all SAVE_EXPRs are recalculated. However, we do
not wish to do that here; the array-size is the same in both
places. */
- if (TREE_CODE (size) == SAVE_EXPR)
- SAVE_EXPR_PERSISTENT_P (size) = 1;
+ if (TREE_CODE (save) == SAVE_EXPR)
+ SAVE_EXPR_PERSISTENT_P (save) = 1;
if ((*lang_hooks.decls.global_bindings_p) ())
{
@@ -190,16 +197,13 @@ variable_size (size)
}
if (immediate_size_expand)
- /* NULL_RTX is not defined; neither is the rtx type.
- Also, we would like to pass const0_rtx here, but don't have it. */
- expand_expr (size, expand_expr (integer_zero_node, NULL_RTX, VOIDmode, 0),
- VOIDmode, 0);
+ expand_expr (save, const0_rtx, VOIDmode, 0);
else if (cfun != 0 && cfun->x_dont_save_pending_sizes_p)
/* The front-end doesn't want us to keep a list of the expressions
that determine sizes for variable size objects. */
;
else
- put_pending_size (size);
+ put_pending_size (save);
return size;
}