From 8e119f1b63d9de421ffdda86e8a710ba30b58d34 Mon Sep 17 00:00:00 2001 From: Erik Edelmann Date: Fri, 10 Mar 2006 23:28:38 +0000 Subject: symbol.c (check_conflict): Allow allocatable function results, except for elemental functions. fortran/ 2006-03-11 Erik Edelmann * symbol.c (check_conflict): Allow allocatable function results, except for elemental functions. * trans-array.c (gfc_trans_allocate_temp_array): Rename to ... (gfc_trans_create_temp_array): ... this, and add new argument callee_alloc. (gfc_trans_array_constructor, gfc_conv_loop_setup): Update call to gfc_trans_allocate_temp_array. * trans-array.h (gfc_trans_allocate_temp_array): Update prototype. * trans-expr.c (gfc_conv_function_call): Use new arg of gfc_trans_create_temp_array avoid pre-allocation of temporary result variables of pointer AND allocatable functions. (gfc_trans_arrayfunc_assign): Return NULL for allocatable functions. * resolve.c (resolve_symbol): Copy value of 'allocatable' attribute from sym->result to sym. testsuite/ 2006-03-08 Paul Thomas Erik Edelmann * gfortran.dg/allocatable_function_1.f90: New. * gfortran.dg/allocatable_function_2.f90: New. From-SVN: r111951 --- gcc/fortran/trans-expr.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gcc/fortran/trans-expr.c') diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index d1570a7..890b880 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1805,6 +1805,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, gfc_formal_arglist *formal; int has_alternate_specifier = 0; bool need_interface_mapping; + bool callee_alloc; gfc_typespec ts; gfc_charlen cl; @@ -1992,11 +1993,12 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, /* Evaluate the bounds of the result, if known. */ gfc_set_loop_bounds_from_array_spec (&mapping, se, sym->result->as); - /* Allocate a temporary to store the result. In case the function - returns a pointer, the temporary will be a shallow copy and - mustn't be deallocated. */ - gfc_trans_allocate_temp_array (&se->pre, &se->post, se->loop, info, - tmp, false, !sym->attr.pointer); + /* Create a temporary to store the result. In case the function + returns a pointer, the temporary will be a shallow copy and + mustn't be deallocated. */ + callee_alloc = sym->attr.allocatable || sym->attr.pointer; + gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, info, tmp, + false, !sym->attr.pointer, callee_alloc); /* Zero the first stride to indicate a temporary. */ tmp = gfc_conv_descriptor_stride (info->descriptor, gfc_rank_cst[0]); @@ -2955,7 +2957,8 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2) return NULL; /* Functions returning pointers need temporaries. */ - if (expr2->symtree->n.sym->attr.pointer) + if (expr2->symtree->n.sym->attr.pointer + || expr2->symtree->n.sym->attr.allocatable) return NULL; /* Check that no LHS component references appear during an array -- cgit v1.1