aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.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-array.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-array.c')
-rw-r--r--gcc/fortran/trans-array.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index a865d57..15f49b5 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -558,20 +558,24 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post,
}
-/* Generate code to allocate and initialize the descriptor for a temporary
+/* Generate code to create and initialize the descriptor for a temporary
array. This is used for both temporaries needed by the scalarizer, and
- functions returning arrays. Adjusts the loop variables to be zero-based,
- and calculates the loop bounds for callee allocated arrays.
- Also fills in the descriptor, data and offset fields of info if known.
- Returns the size of the array, or NULL for a callee allocated array.
+ functions returning arrays. Adjusts the loop variables to be
+ zero-based, and calculates the loop bounds for callee allocated arrays.
+ Allocate the array unless it's callee allocated (we have a callee
+ allocated array if 'callee_alloc' is true, or if loop->to[n] is
+ NULL_TREE for any n). Also fills in the descriptor, data and offset
+ fields of info if known. Returns the size of the array, or NULL for a
+ callee allocated array.
PRE, POST, DYNAMIC and DEALLOC are as for gfc_trans_allocate_array_storage.
*/
tree
-gfc_trans_allocate_temp_array (stmtblock_t * pre, stmtblock_t * post,
- gfc_loopinfo * loop, gfc_ss_info * info,
- tree eltype, bool dynamic, bool dealloc)
+gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
+ gfc_loopinfo * loop, gfc_ss_info * info,
+ tree eltype, bool dynamic, bool dealloc,
+ bool callee_alloc)
{
tree type;
tree desc;
@@ -662,12 +666,14 @@ gfc_trans_allocate_temp_array (stmtblock_t * pre, stmtblock_t * post,
/* Get the size of the array. */
nelem = size;
- if (size)
+ if (size && !callee_alloc)
size = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
TYPE_SIZE_UNIT (gfc_get_element_type (type)));
+ else
+ size = NULL_TREE;
gfc_trans_allocate_array_storage (pre, post, info, size, nelem, dynamic,
- dealloc);
+ dealloc);
if (info->dimen > loop->temp_dim)
loop->temp_dim = info->dimen;
@@ -1417,8 +1423,8 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss)
mpz_clear (size);
}
- gfc_trans_allocate_temp_array (&loop->pre, &loop->post, loop,
- &ss->data.info, type, dynamic, true);
+ gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, &ss->data.info,
+ type, dynamic, true, false);
desc = ss->data.info.descriptor;
offset = gfc_index_zero_node;
@@ -2834,9 +2840,9 @@ gfc_conv_loop_setup (gfc_loopinfo * loop)
memset (&loop->temp_ss->data.info, 0, sizeof (gfc_ss_info));
loop->temp_ss->type = GFC_SS_SECTION;
loop->temp_ss->data.info.dimen = n;
- gfc_trans_allocate_temp_array (&loop->pre, &loop->post, loop,
- &loop->temp_ss->data.info, tmp, false,
- true);
+ gfc_trans_create_temp_array (&loop->pre, &loop->post, loop,
+ &loop->temp_ss->data.info, tmp, false, true,
+ false);
}
for (n = 0; n < loop->temp_dim; n++)