diff options
Diffstat (limited to 'gcc/fortran/trans-array.cc')
-rw-r--r-- | gcc/fortran/trans-array.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index cc50b96..19d69ae 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6885,6 +6885,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree space; tree inittree; bool onstack; + bool back; gcc_assert (!(sym->attr.pointer || sym->attr.allocatable)); @@ -6896,6 +6897,12 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, gcc_assert (GFC_ARRAY_TYPE_P (type)); onstack = TREE_CODE (type) != POINTER_TYPE; + /* In the case of non-dummy symbols with dependencies on an old-fashioned + function result (ie. proc_name = proc_name->result), gfc_add_init_cleanup + must be called with the last, optional argument false so that the alloc- + ation occurs after the processing of the result. */ + back = sym->fn_result_dep; + gfc_init_block (&init); /* Evaluate character string length. */ @@ -6923,7 +6930,8 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, if (onstack) { - gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE); + gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE, + back); return; } @@ -7010,10 +7018,11 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, addr = fold_build1_loc (gfc_get_location (&sym->declared_at), ADDR_EXPR, TREE_TYPE (decl), space); gfc_add_modify (&init, decl, addr); - gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE); + gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE, + back); tmp = NULL_TREE; } - gfc_add_init_cleanup (block, inittree, tmp); + gfc_add_init_cleanup (block, inittree, tmp, back); } |