diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-09-28 02:56:11 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-09-28 02:56:11 +0000 |
commit | 455f19cb1cc13e726b806d792a8808f55aaa9a07 (patch) | |
tree | 36630ae2e63d9c79e59704bfce96a6e0b3b33f2c /gcc/stor-layout.c | |
parent | 081077002d07ddac4094b11b1edd5f8d1175bddd (diff) | |
download | gcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.zip gcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.tar.gz gcc-455f19cb1cc13e726b806d792a8808f55aaa9a07.tar.bz2 |
re PR c++/17642 (internal compiler error: in invert_truthvalue, at fold-const.c:2997)
PR c++/17642
* stor-layout.c (layout_decl): Use fold_convert, not convert.
(bit_from_pos): Likewise.
(byte_from_pos): Likewise.
(pos_from_bit): Likewise.
(normalize_offset): Likewise.
(place_field): Likewise.
(finalize_type_size): Likewise.
(layout_type): Likewise.
* tree.c (build_index_type): Likewise.
PR c++/17642
* cp-tree.h (fold_if_not_in_template): New function.
* call.c (build_conditional_expr): Use fold_if_not_in_template.
(build_cxx_call): Likewise.
* cvt.c (convert_to_complex): Likewise.
(ocp_convert): Likewise.
(convert): Likewise.
(convert_force): Likewise.
* decl.c (compute_array_index_type): Clear
processing_template_decl while folding array bounds.
* pt.c (convert_nontype_argument): Clear
processing_template_decl while processing non-type argument
initialization.
* tree.c (fold_if_not_in_template): New function.
* typeck.c (build_class_member_access_expr): Use
fold_if_not_in_template.
(build_array_ref): Likewise.
(build_binary_op): Likewise. Do not try to optimize computations
when processing templates.
(cp_pointer_int_sum): Use fold_if_not_in_template.
(pointer_diff): Likewise.
(build_unary_op): Likewise.
(build_reinterpret_cast): Likewise.
(get_delta_difference): Likewise.
(expand_ptrmemfunc_cst): Likewise.
(dubious_conversion_warnings): Likewise.
* g++.dg/template/crash23.C: New test.
From-SVN: r88217
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 4ac9340..c86dd54 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -330,8 +330,8 @@ layout_decl (tree decl, unsigned int known_align) } else if (DECL_SIZE_UNIT (decl) == 0) DECL_SIZE_UNIT (decl) - = convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl), - bitsize_unit_node)); + = fold_convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl), + bitsize_unit_node)); if (code != FIELD_DECL) /* For non-fields, update the alignment from the type. */ @@ -540,7 +540,8 @@ tree bit_from_pos (tree offset, tree bitpos) { return size_binop (PLUS_EXPR, bitpos, - size_binop (MULT_EXPR, convert (bitsizetype, offset), + size_binop (MULT_EXPR, + fold_convert (bitsizetype, offset), bitsize_unit_node)); } @@ -548,9 +549,9 @@ tree byte_from_pos (tree offset, tree bitpos) { return size_binop (PLUS_EXPR, offset, - convert (sizetype, - size_binop (TRUNC_DIV_EXPR, bitpos, - bitsize_unit_node))); + fold_convert (sizetype, + size_binop (TRUNC_DIV_EXPR, bitpos, + bitsize_unit_node))); } void @@ -558,9 +559,9 @@ pos_from_bit (tree *poffset, tree *pbitpos, unsigned int off_align, tree pos) { *poffset = size_binop (MULT_EXPR, - convert (sizetype, - size_binop (FLOOR_DIV_EXPR, pos, - bitsize_int (off_align))), + fold_convert (sizetype, + size_binop (FLOOR_DIV_EXPR, pos, + bitsize_int (off_align))), size_int (off_align / BITS_PER_UNIT)); *pbitpos = size_binop (FLOOR_MOD_EXPR, pos, bitsize_int (off_align)); } @@ -580,7 +581,8 @@ normalize_offset (tree *poffset, tree *pbitpos, unsigned int off_align) *poffset = size_binop (PLUS_EXPR, *poffset, - size_binop (MULT_EXPR, convert (sizetype, extra_aligns), + size_binop (MULT_EXPR, + fold_convert (sizetype, extra_aligns), size_int (off_align / BITS_PER_UNIT))); *pbitpos @@ -869,9 +871,9 @@ place_field (record_layout_info rli, tree field) /* First adjust OFFSET by the partial bits, then align. */ rli->offset = size_binop (PLUS_EXPR, rli->offset, - convert (sizetype, - size_binop (CEIL_DIV_EXPR, rli->bitpos, - bitsize_unit_node))); + fold_convert (sizetype, + size_binop (CEIL_DIV_EXPR, rli->bitpos, + bitsize_unit_node))); rli->bitpos = bitsize_zero_node; rli->offset = round_up (rli->offset, desired_align / BITS_PER_UNIT); @@ -1147,9 +1149,9 @@ place_field (record_layout_info rli, tree field) { rli->offset = size_binop (PLUS_EXPR, rli->offset, - convert (sizetype, - size_binop (CEIL_DIV_EXPR, rli->bitpos, - bitsize_unit_node))); + fold_convert (sizetype, + size_binop (CEIL_DIV_EXPR, rli->bitpos, + bitsize_unit_node))); rli->offset = size_binop (PLUS_EXPR, rli->offset, DECL_SIZE_UNIT (field)); rli->bitpos = bitsize_zero_node; @@ -1353,9 +1355,9 @@ finalize_type_size (tree type) result will fit in sizetype. We will get more efficient code using sizetype, so we force a conversion. */ TYPE_SIZE_UNIT (type) - = convert (sizetype, - size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (type), - bitsize_unit_node)); + = fold_convert (sizetype, + size_binop (FLOOR_DIV_EXPR, TYPE_SIZE (type), + bitsize_unit_node)); if (TYPE_SIZE (type) != 0) { @@ -1638,10 +1640,10 @@ layout_type (tree type) /* The initial subtraction should happen in the original type so that (possible) negative values are handled appropriately. */ length = size_binop (PLUS_EXPR, size_one_node, - convert (sizetype, - fold (build2 (MINUS_EXPR, - TREE_TYPE (lb), - ub, lb)))); + fold_convert (sizetype, + fold (build2 (MINUS_EXPR, + TREE_TYPE (lb), + ub, lb)))); /* Special handling for arrays of bits (for Chill). */ element_size = TYPE_SIZE (element); @@ -1670,7 +1672,8 @@ layout_type (tree type) length = size_binop (MAX_EXPR, length, size_zero_node); TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size, - convert (bitsizetype, length)); + fold_convert (bitsizetype, + length)); /* If we know the size of the element, calculate the total size directly, rather than do some division thing below. |