Commit cd55d18e by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR fortran/54833 (Don't wrap __builtin_free(a) in if (a != NULL))

	PR fortran/54833
	* trans.c (gfc_call_free): Don't check if pointer is NULL.
	* trans.h (gfc_call_free): Adjust comment.

From-SVN: r227336
parent e7854993
2015-08-31 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/54833
* trans.c (gfc_call_free): Don't check if pointer is NULL.
* trans.h (gfc_call_free): Adjust comment.
2015-08-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2015-08-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* trans.c (gfc_call_malloc, gfc_allocate_using_malloc, * trans.c (gfc_call_malloc, gfc_allocate_using_malloc,
......
...@@ -850,23 +850,14 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token, ...@@ -850,23 +850,14 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token,
} }
/* Free a given variable, if it's not NULL. */ /* Free a given variable. */
tree tree
gfc_call_free (tree var) gfc_call_free (tree var)
{ {
tree cond, call; return build_call_expr_loc (input_location,
/* Only evaluate the variable once. */
var = save_expr (fold_convert (pvoid_type_node, var));
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), builtin_decl_explicit (BUILT_IN_FREE),
1, var); 1, fold_convert (pvoid_type_node, var));
return fold_build3_loc (input_location, COND_EXPR, void_type_node,
cond, call, build_empty_stmt (input_location));
} }
......
...@@ -642,7 +642,7 @@ void gfc_trans_runtime_check (bool, bool, tree, stmtblock_t *, locus *, ...@@ -642,7 +642,7 @@ void gfc_trans_runtime_check (bool, bool, tree, stmtblock_t *, locus *,
void gfc_trans_same_strlen_check (const char*, locus*, tree, tree, void gfc_trans_same_strlen_check (const char*, locus*, tree, tree,
stmtblock_t*); stmtblock_t*);
/* Generate a call to free() after checking that its arg is non-NULL. */ /* Generate a call to free(). */
tree gfc_call_free (tree); tree gfc_call_free (tree);
/* Allocate memory after performing a few checks. */ /* Allocate memory after performing a few checks. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment