summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authortobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-24 16:43:23 +0000
committertobi <tobi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-24 16:43:23 +0000
commitf75d6b8acd6d0ea7831df775302a24bbd006afe1 (patch)
tree405bd7396b605b64b780b51b408b0d9c87bcc36e /gcc/fortran/trans-array.c
parent100b67dab1b474045ad0fe0136894bf545caa23e (diff)
downloadgcc-f75d6b8acd6d0ea7831df775302a24bbd006afe1.tar.gz
* trans-array.c (gfc_conv_descriptor_data_get,
gfc_conv_descriptor_data_set_internal, gfc_conv_descriptor_data_addr, gfc_conv_descriptor_offset, gfc_conv_descriptor_dtype, gfc_conv_descriptor_dimension, gfc_conv_descriptor_stride, gfc_conv_descriptor_lbound, gfc_conv_descriptor_ubound, gfc_trans_create_temp_array, gfc_conv_array_transpose, gfc_grow_array, gfc_trans_array_constructor_subarray, gfc_trans_array_constructor_value, gfc_trans_scalarized_loop_end, gfc_array_init_size, gfc_array_allocate, gfc_array_deallocate, gfc_conv_array_initializer, gfc_trans_array_bounds, gfc_trans_auto_array_allocation, gfc_trans_dummy_array_bias, gfc_get_dataptr_offset, gfc_conv_array_parameter, gfc_trans_dealloc_allocated, get_full_array_size, gfc_duplicate_allocatable, structure_alloc_comps): Use fold_buildN instead of buildN. * trans-expr.c (gfc_conv_expr_present, gfc_conv_missing_dummy, gfc_conv_component_ref, gfc_conv_cst_int_power, gfc_conv_function_call, gfc_trans_structur_assign): Likewise. * trans-common.c (create_common): Likewise. * trans-openmp.c (gfc_trans_omp_atomic, gfc_trans_omp_do): Likewise. * trans-const.c (gfc_conv_constant_to_tree): Likewise. * trans-stmt.c (gfc_trans_goto, gfc_trans_return, gfc_trans_do, gfc_trans_integer_select, gfc_trans_character_select, gfc_trans_forall_loop, compute_overall_iter_number, gfc_trans_forall_1, gfc_evaluate_where_mask, gfc_trans_allocate, gfc_trans_deallocate): Likewise. * trans.c (gfc_build_addr_expr, gfc_trans_runtime_check, gfc_allocate_with_status, gfc_allocate_array_with_status, gfc_deallocate_with_status): Likewise. * f95-lang.c (gfc_truthvalue_conversion): Likewise. * trans-io.c (set_parameter_const, set_parameter_value, set_parameter_ref, set_string, set_internal_unit, io_result, set_error_locus, nml_get_addr_expr, transfer_expr): Likewise. * trans-decl.c (gfc_build_qualified_array, build_entry_thunks, gfc_get_fake_result_decl, gfc_trans_auto_character_variable, gfc_generate_function_code): Likewise. * convert.c (convert): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_conversion, build_fixbound_expr, build_fix_expr, gfc_conv_intrinsic_aint, gfc_conv_intrinsic_int, gfc_conv_intrinsic_imagpart, gfc_conv_intrinsic_conjg, gfc_conv_intrinsic_abs, gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_mod, gfc_conv_intrinsic_dim, gfc_conv_intrinsic_dprod, gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate, gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax, gfc_conv_intrinsic_minmax_char, gfc_conv_intrinsic_count, gfc_conv_intrinsic_arith, gfc_conv_intrinsic_dot_product, gfc_conv_intrinsic_minmaxloc, gfc_conv_intrinsic_minmaxval, gfc_conv_intrinsic_btest, gfc_conv_intrinsic_not, gfc_conv_intrinsic_ibits, gfc_conv_intrinsic_ishft, gfc_conv_intrinsic_ichar, gfc_conv_intrinsic_size, gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer, gfc_conv_allocated, gfc_conv_associated, gfc_conv_intrinsic_trim, gfc_conv_intrinsic_repeat): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132592 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c163
1 files changed, 91 insertions, 72 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 41f01b848f2..07b0f60c86d 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -1,5 +1,5 @@
/* Array translation routines
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
and Steven Bosscher <s.bosscher@student.tudelft.nl>
@@ -149,7 +149,7 @@ gfc_conv_descriptor_data_get (tree desc)
field = TYPE_FIELDS (type);
gcc_assert (DATA_FIELD == 0);
- t = build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
t = fold_convert (GFC_TYPE_ARRAY_DATAPTR_TYPE (type), t);
return t;
@@ -176,7 +176,7 @@ gfc_conv_descriptor_data_set_internal (stmtblock_t *block,
field = TYPE_FIELDS (type);
gcc_assert (DATA_FIELD == 0);
- t = build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
gfc_add_modify (block, t, fold_convert (TREE_TYPE (field), value), tuples_p);
}
@@ -195,7 +195,7 @@ gfc_conv_descriptor_data_addr (tree desc)
field = TYPE_FIELDS (type);
gcc_assert (DATA_FIELD == 0);
- t = build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ t = fold_build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
return build_fold_addr_expr (t);
}
@@ -211,7 +211,8 @@ gfc_conv_descriptor_offset (tree desc)
field = gfc_advance_chain (TYPE_FIELDS (type), OFFSET_FIELD);
gcc_assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type);
- return build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ return fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ desc, field, NULL_TREE);
}
tree
@@ -226,7 +227,8 @@ gfc_conv_descriptor_dtype (tree desc)
field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD);
gcc_assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type);
- return build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ return fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ desc, field, NULL_TREE);
}
static tree
@@ -244,7 +246,8 @@ gfc_conv_descriptor_dimension (tree desc, tree dim)
&& TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (TREE_TYPE (field))) == RECORD_TYPE);
- tmp = build3 (COMPONENT_REF, TREE_TYPE (field), desc, field, NULL_TREE);
+ tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ desc, field, NULL_TREE);
tmp = gfc_build_array_ref (tmp, dim, NULL);
return tmp;
}
@@ -260,7 +263,8 @@ gfc_conv_descriptor_stride (tree desc, tree dim)
field = gfc_advance_chain (field, STRIDE_SUBFIELD);
gcc_assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type);
- tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE);
+ tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ tmp, field, NULL_TREE);
return tmp;
}
@@ -275,7 +279,8 @@ gfc_conv_descriptor_lbound (tree desc, tree dim)
field = gfc_advance_chain (field, LBOUND_SUBFIELD);
gcc_assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type);
- tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE);
+ tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ tmp, field, NULL_TREE);
return tmp;
}
@@ -290,7 +295,8 @@ gfc_conv_descriptor_ubound (tree desc, tree dim)
field = gfc_advance_chain (field, UBOUND_SUBFIELD);
gcc_assert (field != NULL_TREE && TREE_TYPE (field) == gfc_array_index_type);
- tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE);
+ tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ tmp, field, NULL_TREE);
return tmp;
}
@@ -641,9 +647,10 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
{
/* For a callee allocated array express the loop bounds in terms
of the descriptor fields. */
- tmp = build2 (MINUS_EXPR, gfc_array_index_type,
- gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]),
- gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n]));
+ tmp =
+ fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]),
+ gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n]));
loop->to[n] = tmp;
size = NULL_TREE;
continue;
@@ -774,9 +781,10 @@ gfc_conv_array_transpose (gfc_se * se, gfc_expr * expr)
if (!loop->to[n])
{
gcc_assert (integer_zerop (loop->from[n]));
- loop->to[n] = build2 (MINUS_EXPR, gfc_array_index_type,
- gfc_conv_descriptor_ubound (dest, dest_index),
- gfc_conv_descriptor_lbound (dest, dest_index));
+ loop->to[n] =
+ fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ gfc_conv_descriptor_ubound (dest, dest_index),
+ gfc_conv_descriptor_lbound (dest, dest_index));
}
}
@@ -835,7 +843,7 @@ gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
ubound = gfc_conv_descriptor_ubound (desc, gfc_rank_cst[0]);
/* Add EXTRA to the upper bound. */
- tmp = build2 (PLUS_EXPR, gfc_array_index_type, ubound, extra);
+ tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, ubound, extra);
gfc_add_modify_expr (pblock, ubound, tmp);
/* Get the value of the current data pointer. */
@@ -843,9 +851,11 @@ gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
/* Calculate the new array size. */
size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (desc)));
- tmp = build2 (PLUS_EXPR, gfc_array_index_type, ubound, gfc_index_one_node);
- arg1 = build2 (MULT_EXPR, size_type_node, fold_convert (size_type_node, tmp),
- fold_convert (size_type_node, size));
+ tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
+ ubound, gfc_index_one_node);
+ arg1 = fold_build2 (MULT_EXPR, size_type_node,
+ fold_convert (size_type_node, tmp),
+ fold_convert (size_type_node, size));
/* Call the realloc() function. */
tmp = gfc_call_realloc (pblock, arg0, arg1);
@@ -1084,7 +1094,8 @@ gfc_trans_array_constructor_subarray (stmtblock_t * pblock,
gcc_assert (se.ss == gfc_ss_terminator);
/* Increment the offset. */
- tmp = build2 (PLUS_EXPR, gfc_array_index_type, *poffset, gfc_index_one_node);
+ tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
+ *poffset, gfc_index_one_node);
gfc_add_modify_expr (&body, *poffset, tmp);
/* Finish the loop. */
@@ -1317,10 +1328,10 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
tmp = fold_build2 (GT_EXPR, boolean_type_node, step,
build_int_cst (TREE_TYPE (step), 0));
cond = fold_build3 (COND_EXPR, boolean_type_node, tmp,
- build2 (GT_EXPR, boolean_type_node,
- loopvar, end),
- build2 (LT_EXPR, boolean_type_node,
- loopvar, end));
+ fold_build2 (GT_EXPR, boolean_type_node,
+ loopvar, end),
+ fold_build2 (LT_EXPR, boolean_type_node,
+ loopvar, end));
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
@@ -1330,7 +1341,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
gfc_add_expr_to_block (&body, loopbody);
/* Increase loop variable by step. */
- tmp = build2 (PLUS_EXPR, TREE_TYPE (loopvar), loopvar, step);
+ tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (loopvar), loopvar, step);
gfc_add_modify_expr (&body, loopvar, tmp);
/* Finish the loop. */
@@ -2568,7 +2579,8 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
gfc_init_block (&block);
/* The exit condition. */
- cond = build2 (GT_EXPR, boolean_type_node, loop->loopvar[n], loop->to[n]);
+ cond = fold_build2 (GT_EXPR, boolean_type_node,
+ loop->loopvar[n], loop->to[n]);
tmp = build1_v (GOTO_EXPR, exit_label);
TREE_USED (exit_label) = 1;
tmp = build3_v (COND_EXPR, cond, tmp, build_empty_stmt ());
@@ -2578,8 +2590,8 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n,
gfc_add_expr_to_block (&block, loopbody);
/* Increment the loopvar. */
- tmp = build2 (PLUS_EXPR, gfc_array_index_type,
- loop->loopvar[n], gfc_index_one_node);
+ tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
+ loop->loopvar[n], gfc_index_one_node);
gfc_add_modify_expr (&block, loop->loopvar[n], tmp);
/* Build the loop. */
@@ -3563,8 +3575,8 @@ gfc_array_init_size (tree descriptor, int rank, tree * poffset,
offset = fold_build2 (MINUS_EXPR, gfc_array_index_type, offset, tmp);
/* Start the calculation for the size of this dimension. */
- size = build2 (MINUS_EXPR, gfc_array_index_type,
- gfc_index_one_node, se.expr);
+ size = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ gfc_index_one_node, se.expr);
/* Set upper bound. */
gfc_init_se (&se, NULL);
@@ -3700,7 +3712,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree pstat)
tmp = gfc_allocate_array_with_status (&se->pre, pointer, size, pstat);
else
tmp = gfc_allocate_with_status (&se->pre, size, pstat);
- tmp = build2 (MODIFY_EXPR, void_type_node, pointer, tmp);
+ tmp = fold_build2 (MODIFY_EXPR, void_type_node, pointer, tmp);
gfc_add_expr_to_block (&se->pre, tmp);
tmp = gfc_conv_descriptor_offset (se->expr);
@@ -3739,8 +3751,8 @@ gfc_array_deallocate (tree descriptor, tree pstat)
gfc_add_expr_to_block (&block, tmp);
/* Zero the data pointer. */
- tmp = build2 (MODIFY_EXPR, void_type_node,
- var, build_int_cst (TREE_TYPE (var), 0));
+ tmp = fold_build2 (MODIFY_EXPR, void_type_node,
+ var, build_int_cst (TREE_TYPE (var), 0));
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
@@ -3825,7 +3837,7 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
else
tmp1 = gfc_conv_mpz_to_tree (c->n.offset, gfc_index_integer_kind);
- range = build2 (RANGE_EXPR, integer_type_node, tmp1, tmp2);
+ range = fold_build2 (RANGE_EXPR, integer_type_node, tmp1, tmp2);
}
else
range = NULL;
@@ -3937,10 +3949,10 @@ gfc_trans_array_bounds (tree type, gfc_symbol * sym, tree * poffset,
/* Make sure that negative size arrays are translated
to being zero size. */
- tmp = build2 (GE_EXPR, boolean_type_node,
- stride, gfc_index_zero_node);
- tmp = build3 (COND_EXPR, gfc_array_index_type, tmp,
- stride, gfc_index_zero_node);
+ tmp = fold_build2 (GE_EXPR, boolean_type_node,
+ stride, gfc_index_zero_node);
+ tmp = fold_build3 (COND_EXPR, gfc_array_index_type, tmp,
+ stride, gfc_index_zero_node);
gfc_add_modify_expr (pblock, stride, tmp);
}
@@ -3988,7 +4000,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody)
/* Emit a DECL_EXPR for this variable, which will cause the
gimplifier to allocate storage, and all that good stuff. */
- tmp = build1 (DECL_EXPR, TREE_TYPE (decl), decl);
+ tmp = fold_build1 (DECL_EXPR, TREE_TYPE (decl), decl);
gfc_add_expr_to_block (&block, tmp);
}
@@ -4195,9 +4207,10 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
stride = gfc_conv_descriptor_stride (dumdesc, gfc_rank_cst[0]);
stride = gfc_evaluate_now (stride, &block);
- tmp = build2 (EQ_EXPR, boolean_type_node, stride, gfc_index_zero_node);
- tmp = build3 (COND_EXPR, gfc_array_index_type, tmp,
- gfc_index_one_node, stride);
+ tmp = fold_build2 (EQ_EXPR, boolean_type_node,
+ stride, gfc_index_zero_node);
+ tmp = fold_build3 (COND_EXPR, gfc_array_index_type, tmp,
+ gfc_index_one_node, stride);
stride = GFC_TYPE_ARRAY_STRIDE (type, 0);
gfc_add_modify_expr (&block, stride, tmp);
@@ -4225,8 +4238,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
if (stmt_packed != NULL_TREE && stmt_unpacked != NULL_TREE)
{
/* Don't repack unknown shape arrays when the first stride is 1. */
- tmp = build3 (COND_EXPR, TREE_TYPE (stmt_packed), partial,
- stmt_packed, stmt_unpacked);
+ tmp = fold_build3 (COND_EXPR, TREE_TYPE (stmt_packed),
+ partial, stmt_packed, stmt_unpacked);
}
else
tmp = stmt_packed != NULL_TREE ? stmt_packed : stmt_unpacked;
@@ -4282,8 +4295,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
ubound, lbound);
- stride2 = build2 (MINUS_EXPR, gfc_array_index_type,
- dubound, dlbound);
+ stride2 = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ dubound, dlbound);
tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride2);
asprintf (&msg, "%s for dimension %d of array '%s'",
gfc_msg_bounds, n+1, sym->name);
@@ -4295,7 +4308,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
{
/* For assumed shape arrays move the upper bound by the same amount
as the lower bound. */
- tmp = build2 (MINUS_EXPR, gfc_array_index_type, dubound, dlbound);
+ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ dubound, dlbound);
tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, tmp, lbound);
gfc_add_modify_expr (&block, ubound, tmp);
}
@@ -4333,8 +4347,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
/* Assign the stride. */
if (stmt_packed != NULL_TREE && stmt_unpacked != NULL_TREE)
- tmp = build3 (COND_EXPR, gfc_array_index_type, partial,
- stmt_unpacked, stmt_packed);
+ tmp = fold_build3 (COND_EXPR, gfc_array_index_type, partial,
+ stmt_unpacked, stmt_packed);
else
tmp = (stmt_packed != NULL_TREE) ? stmt_packed : stmt_unpacked;
gfc_add_modify_expr (&block, stride, tmp);
@@ -4404,7 +4418,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body)
/* Only do the cleanup if the array was repacked. */
tmp = build_fold_indirect_ref (dumdesc);
tmp = gfc_conv_descriptor_data_get (tmp);
- tmp = build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc);
+ tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc);
stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
if (optional_arg)
@@ -4468,7 +4482,8 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, tree offset,
case REF_COMPONENT:
field = ref->u.c.component->backend_decl;
gcc_assert (field && TREE_CODE (field) == FIELD_DECL);
- tmp = build3 (COMPONENT_REF, TREE_TYPE (field), tmp, field, NULL_TREE);
+ tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field),
+ tmp, field, NULL_TREE);
break;
case REF_SUBSTRING:
@@ -5151,8 +5166,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77)
loop cleanup code. */
tmp = build_fold_indirect_ref (desc);
tmp = gfc_conv_array_data (tmp);
- tmp = build2 (NE_EXPR, boolean_type_node,
- fold_convert (TREE_TYPE (tmp), ptr), tmp);
+ tmp = fold_build2 (NE_EXPR, boolean_type_node,
+ fold_convert (TREE_TYPE (tmp), ptr), tmp);
tmp = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt ());
gfc_add_expr_to_block (&block, tmp);
@@ -5185,8 +5200,8 @@ gfc_trans_dealloc_allocated (tree descriptor)
gfc_add_expr_to_block (&block, tmp);
/* Zero the data pointer. */
- tmp = build2 (MODIFY_EXPR, void_type_node,
- var, build_int_cst (TREE_TYPE (var), 0));
+ tmp = fold_build2 (MODIFY_EXPR, void_type_node,
+ var, build_int_cst (TREE_TYPE (var), 0));
gfc_add_expr_to_block (&block, tmp);
return gfc_finish_block (&block);
@@ -5204,13 +5219,13 @@ get_full_array_size (stmtblock_t *block, tree decl, int rank)
idx = gfc_rank_cst[rank - 1];
nelems = gfc_conv_descriptor_ubound (decl, idx);
tmp = gfc_conv_descriptor_lbound (decl, idx);
- tmp = build2 (MINUS_EXPR, gfc_array_index_type, nelems, tmp);
- tmp = build2 (PLUS_EXPR, gfc_array_index_type,
- tmp, gfc_index_one_node);
+ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, nelems, tmp);
+ tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
+ tmp, gfc_index_one_node);
tmp = gfc_evaluate_now (tmp, block);
nelems = gfc_conv_descriptor_stride (decl, idx);
- tmp = build2 (MULT_EXPR, gfc_array_index_type, nelems, tmp);
+ tmp = fold_build2 (MULT_EXPR, gfc_array_index_type, nelems, tmp);
return gfc_evaluate_now (tmp, block);
}
@@ -5256,8 +5271,8 @@ gfc_duplicate_allocatable(tree dest, tree src, tree type, int rank)
the allocate and copy. */
null_cond = gfc_conv_descriptor_data_get (src);
null_cond = convert (pvoid_type_node, null_cond);
- null_cond = build2 (NE_EXPR, boolean_type_node, null_cond,
- null_pointer_node);
+ null_cond = fold_build2 (NE_EXPR, boolean_type_node,
+ null_cond, null_pointer_node);
return build3_v (COND_EXPR, null_cond, tmp, null_data);
}
@@ -5307,12 +5322,12 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
is a full array reference, we only need the descriptor
information from dimension = rank. */
tmp = get_full_array_size (&fnblock, decl, rank);
- tmp = build2 (MINUS_EXPR, gfc_array_index_type,
- tmp, gfc_index_one_node);
+ tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ tmp, gfc_index_one_node);
null_cond = gfc_conv_descriptor_data_get (decl);
- null_cond = build2 (NE_EXPR, boolean_type_node, null_cond,
- build_int_cst (TREE_TYPE (null_cond), 0));
+ null_cond = fold_build2 (NE_EXPR, boolean_type_node, null_cond,
+ build_int_cst (TREE_TYPE (null_cond), 0));
}
else
{
@@ -5376,7 +5391,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
components. */
if (cmp_has_alloc_comps && !c->pointer)
{
- comp = build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
+ comp = fold_build3 (COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
rank = c->as ? c->as->rank : 0;
tmp = structure_alloc_comps (c->ts.derived, comp, NULL_TREE,
rank, purpose);
@@ -5385,7 +5401,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
if (c->allocatable)
{
- comp = build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
+ comp = fold_build3 (COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
tmp = gfc_trans_dealloc_allocated (comp);
gfc_add_expr_to_block (&fnblock, tmp);
}
@@ -5396,12 +5413,14 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
continue;
else if (c->allocatable)
{
- comp = build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
+ comp = fold_build3 (COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
gfc_conv_descriptor_data_set (&fnblock, comp, null_pointer_node);
}
else if (cmp_has_alloc_comps)
{
- comp = build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
+ comp = fold_build3 (COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
rank = c->as ? c->as->rank : 0;
tmp = structure_alloc_comps (c->ts.derived, comp, NULL_TREE,
rank, purpose);
@@ -5414,8 +5433,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
continue;
/* We need source and destination components. */
- comp = build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
- dcmp = build3 (COMPONENT_REF, ctype, dest, cdecl, NULL_TREE);
+ comp = fold_build3 (COMPONENT_REF, ctype, decl, cdecl, NULL_TREE);
+ dcmp = fold_build3 (COMPONENT_REF, ctype, dest, cdecl, NULL_TREE);
dcmp = fold_convert (TREE_TYPE (comp), dcmp);
if (c->allocatable && !cmp_has_alloc_comps)