diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2012-10-27 12:07:26 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2012-10-27 12:07:26 +0000 |
commit | 7999d7b4e6f6a225d8afddd54fd499ec6448a0cd (patch) | |
tree | 40066fef0f04e105095f8eaf3a5e7f55fa88fbc7 /gcc | |
parent | 38d233a928cf70b351c67987280c0c3169cf0241 (diff) | |
download | gcc-7999d7b4e6f6a225d8afddd54fd499ec6448a0cd.zip gcc-7999d7b4e6f6a225d8afddd54fd499ec6448a0cd.tar.gz gcc-7999d7b4e6f6a225d8afddd54fd499ec6448a0cd.tar.bz2 |
trans.c (gfc_allocate_allocatable): Revert accidental commit.
2012-10-27 Thomas Koenig <tkoenig@gcc.gnu.org>
* trans.c (gfc_allocate_allocatable): Revert accidental
commit.
From-SVN: r192875
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/trans.c | 28 |
2 files changed, 17 insertions, 16 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 25928e1..25e5f0b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2012-10-27 Thomas Koenig <tkoenig@gcc.gnu.org> + + * trans.c (gfc_allocate_allocatable): Revert accidental + commit. + 2012-10-24 Janus Weil <janus@gcc.gnu.org> PR fortran/55037 diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 7c2d472..6365213 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -814,23 +814,26 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token, } -/* Free a given variable. If it is NULL, free takes care of this - automatically. */ +/* Free a given variable, if it's not NULL. */ tree gfc_call_free (tree var) { stmtblock_t block; - tree call; + tree tmp, cond, call; if (TREE_TYPE (var) != TREE_TYPE (pvoid_type_node)) var = 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); - gfc_add_expr_to_block (&block, call); + 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); } @@ -858,10 +861,11 @@ gfc_call_free (tree var) } } - In this front-end version, status doesn't have to be GFC_INTEGER_4. If - CAN_FAIL is true, no status variable is passed and we are not dealing with - a coarray, we will simply call free(). This is used for unconditional - deallocation generated by the front-end at end of each procedure. + In this front-end version, status doesn't have to be GFC_INTEGER_4. + Moreover, if CAN_FAIL is true, then we will not emit a runtime error, + even when no status variable is passed to us (this is used for + unconditional deallocation generated by the front-end at end of + each procedure). If a runtime-message is possible, `expr' must point to the original expression being deallocated for its locus and variable name. @@ -886,14 +890,6 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, STRIP_NOPS (pointer); } - else if (can_fail && status == NULL_TREE) - { - tmp = build_call_expr_loc (input_location, - builtin_decl_explicit (BUILT_IN_FREE), 1, - fold_convert (pvoid_type_node, pointer)); - return tmp; - } - cond = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, pointer, build_int_cst (TREE_TYPE (pointer), 0)); |