gfc_add_modify (&se->pre, var, tmp);
/* Free the temporary afterwards. */
- tmp = gfc_call_free (convert (pvoid_type_node, var));
+ tmp = gfc_call_free (var);
gfc_add_expr_to_block (&se->post, tmp);
}
gfc_add_modify (&se->pre, var,
fold_convert (TREE_TYPE (var),
null_pointer_node));
- tmp = gfc_call_free (convert (pvoid_type_node, var));
+ tmp = gfc_call_free (var);
gfc_add_expr_to_block (&se->post, tmp);
}
if (se->ss && se->ss->loop)
{
gfc_add_expr_to_block (&se->ss->loop->post, tmp);
- tmp = gfc_call_free (convert (pvoid_type_node, info->data));
+ tmp = gfc_call_free (info->data);
gfc_add_expr_to_block (&se->ss->loop->post, tmp);
}
else
{
gfc_add_expr_to_block (&se->post, tmp);
tmp = gfc_class_data_get (se->expr);
- tmp = gfc_call_free (convert (pvoid_type_node, tmp));
+ tmp = gfc_call_free (tmp);
gfc_add_expr_to_block (&se->post, tmp);
}
expr->must_finalize = 0;
boolean_type_node, tmp,
build_int_cst (TREE_TYPE (tmp), 0));
zero_cond = gfc_evaluate_now (zero_cond, &se->post);
- tmp = gfc_call_free (fold_convert (pvoid_type_node, tmp));
+ tmp = gfc_call_free (tmp);
gfc_add_expr_to_block (&se->post, tmp);
tmp = gfc_conv_descriptor_data_get (res_desc);
tree tmp, msg, malloc_result, null_result, res, malloc_tree;
stmtblock_t block2;
- size = gfc_evaluate_now (size, block);
-
- if (TREE_TYPE (size) != TREE_TYPE (size_type_node))
- size = fold_convert (size_type_node, size);
-
/* Create a variable to hold the result. */
res = gfc_create_var (prvoid_type_node, NULL);
/* Call malloc. */
gfc_start_block (&block2);
+ size = fold_convert (size_type_node, size);
size = fold_build2_loc (input_location, MAX_EXPR, size_type_node, size,
build_int_cst (size_type_node, 1));
}
malloc_result = gfc_finish_block (&block2);
-
gfc_add_expr_to_block (block, malloc_result);
if (type != NULL)
stmtblock_t on_error;
tree status_type = status ? TREE_TYPE (status) : NULL_TREE;
- /* Evaluate size only once, and make sure it has the right type. */
- size = gfc_evaluate_now (size, block);
- if (TREE_TYPE (size) != TREE_TYPE (size_type_node))
- size = fold_convert (size_type_node, size);
-
/* If successful and stat= is given, set status to 0. */
if (status != NULL_TREE)
gfc_add_expr_to_block (block,
status, build_int_cst (status_type, 0)));
/* The allocation itself. */
+ size = fold_convert (size_type_node, size);
gfc_add_modify (block, pointer,
fold_convert (TREE_TYPE (pointer),
build_call_expr_loc (input_location,
gcc_assert (token != NULL_TREE);
- /* Evaluate size only once, and make sure it has the right type. */
- size = gfc_evaluate_now (size, block);
- if (TREE_TYPE (size) != TREE_TYPE (size_type_node))
- size = fold_convert (size_type_node, size);
-
/* The allocation itself. */
if (status == NULL_TREE)
pstat = null_pointer_node;
errlen = build_int_cst (integer_type_node, 0);
}
+ size = fold_convert (size_type_node, size);
tmp = build_call_expr_loc (input_location,
gfor_fndecl_caf_register, 6,
fold_build2_loc (input_location,
tree tmp, null_mem, alloc, error;
tree type = TREE_TYPE (mem);
- if (TREE_TYPE (size) != TREE_TYPE (size_type_node))
- size = fold_convert (size_type_node, size);
-
+ size = fold_convert (size_type_node, size);
null_mem = gfc_unlikely (fold_build2_loc (input_location, NE_EXPR,
boolean_type_node, mem,
build_int_cst (type, 0)),
/* Free a given variable, if it's not NULL. */
+
tree
gfc_call_free (tree var)
{
- stmtblock_t block;
- tree tmp, cond, call;
+ tree cond, call;
- if (TREE_TYPE (var) != TREE_TYPE (pvoid_type_node))
- var = fold_convert (pvoid_type_node, var);
+ /* Only evaluate the variable once. */
+ var = save_expr (fold_convert (pvoid_type_node, var));
- gfc_start_block (&block);
- var = gfc_evaluate_now (var, &block);
cond = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, var,
build_int_cst (pvoid_type_node, 0));
call = build_call_expr_loc (input_location,
builtin_decl_explicit (BUILT_IN_FREE),
1, var);
- tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, call,
- build_empty_stmt (input_location));
- gfc_add_expr_to_block (&block, tmp);
-
- return gfc_finish_block (&block);
+ return fold_build3_loc (input_location, COND_EXPR, void_type_node,
+ cond, call, build_empty_stmt (input_location));
}
tree msg, res, nonzero, null_result, tmp;
tree type = TREE_TYPE (mem);
- size = gfc_evaluate_now (size, block);
-
- if (TREE_TYPE (size) != TREE_TYPE (size_type_node))
- size = fold_convert (size_type_node, size);
+ /* Only evaluate the size once. */
+ size = save_expr (fold_convert (size_type_node, size));
/* Create a variable to hold the result. */
res = gfc_create_var (type, NULL);