summaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-02 15:22:54 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-05-02 15:22:54 +0000
commita3f07b52ffd9a68144540599289b0cdd17e4498e (patch)
treeaba2d31b13dea7131e7eb941ca9a452f462c9085 /gcc/varasm.c
parent6fe5844bf900d029b25393343f1330de9d04b7cf (diff)
downloadgcc-a3f07b52ffd9a68144540599289b0cdd17e4498e.tar.gz
2011-05-02 Richard Guenther <rguenther@suse.de>
* varasm.c (output_constructor_regular_field): Compute zero-based index with double-ints. Make sure to ICE instead of producing wrong code. * cgraph.c (cgraph_add_thunk): Do not create new tree nodes in asserts. Properly use a signed type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173255 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 8755dded36e..b4f38058e22 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4711,9 +4711,13 @@ output_constructor_regular_field (oc_local_state *local)
unsigned int align2;
if (local->index != NULL_TREE)
- fieldpos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (local->val)), 1)
- * ((tree_low_cst (local->index, 0)
- - tree_low_cst (local->min_index, 0))));
+ {
+ double_int idx = double_int_sub (tree_to_double_int (local->index),
+ tree_to_double_int (local->min_index));
+ gcc_assert (double_int_fits_in_shwi_p (idx));
+ fieldpos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (local->val)), 1)
+ * idx.low);
+ }
else if (local->field != NULL_TREE)
fieldpos = int_byte_position (local->field);
else
@@ -4760,13 +4764,8 @@ output_constructor_regular_field (oc_local_state *local)
better be last. */
gcc_assert (!fieldsize || !DECL_CHAIN (local->field));
}
- else if (DECL_SIZE_UNIT (local->field))
- {
- /* ??? This can't be right. If the decl size overflows
- a host integer we will silently emit no data. */
- if (host_integerp (DECL_SIZE_UNIT (local->field), 1))
- fieldsize = tree_low_cst (DECL_SIZE_UNIT (local->field), 1);
- }
+ else
+ fieldsize = tree_low_cst (DECL_SIZE_UNIT (local->field), 1);
}
else
fieldsize = int_size_in_bytes (TREE_TYPE (local->type));