aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorErik Edelmann <eedelman@gcc.gnu.org>2006-03-10 23:28:38 +0000
committerErik Edelmann <eedelman@gcc.gnu.org>2006-03-10 23:28:38 +0000
commit8e119f1b63d9de421ffdda86e8a710ba30b58d34 (patch)
treedf22f386bb6af80823879f5088a1bd3c99fb5e8f /gcc/fortran/trans-expr.c
parentea725d4524db8fa1bc593f5aa0e297a01ab721f3 (diff)
downloadgcc-8e119f1b63d9de421ffdda86e8a710ba30b58d34.zip
gcc-8e119f1b63d9de421ffdda86e8a710ba30b58d34.tar.gz
gcc-8e119f1b63d9de421ffdda86e8a710ba30b58d34.tar.bz2
symbol.c (check_conflict): Allow allocatable function results, except for elemental functions.
fortran/ 2006-03-11 Erik Edelmann <eedelman@gcc.gnu.org> * 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 <pault@gcc.gnu.org> Erik Edelmann <eedelman@gcc.gnu.org> * gfortran.dg/allocatable_function_1.f90: New. * gfortran.dg/allocatable_function_2.f90: New. From-SVN: r111951
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c15
1 files changed, 9 insertions, 6 deletions
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