This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch,fortran] Allocatable dummy-fix
Ping.
On Wed, Mar 22, 2006 at 12:47:47AM +0200, Erik Edelmann wrote:
> On Mon, Mar 20, 2006 at 11:13:42PM +0200, Erik Edelmann wrote:
> > In addition, I've moved the getting of the tree representation of
> > the array to be deallocated out of trans-array.c
> > (gfc_trans_dealloc_allocated) to the caller.
>
> One could of course ask why I renamed the variable 'descriptor'
> to 'array'. I see no particular reason. Probably better to
> stick to the old name. New patch below.
>
>
> Erik
> Index: gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90
> ===================================================================
> --- gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 (revision 112225)
> +++ gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 (working copy)
> @@ -33,7 +33,7 @@ contains
> integer, allocatable, intent(in) :: x(:)
> integer, allocatable, intent(out) :: y(:)
> if (allocated(y)) call abort()
> - allocate (y(3))
> + call init(y)
> y = x
> end subroutine useit
>
> Index: gcc/fortran/trans-expr.c
> ===================================================================
> --- gcc/fortran/trans-expr.c (revision 112225)
> +++ gcc/fortran/trans-expr.c (working copy)
> @@ -1920,7 +1920,10 @@ gfc_conv_function_call (gfc_se * se, gfc
> if (formal && formal->sym->attr.allocatable
> && formal->sym->attr.intent == INTENT_OUT)
> {
> - tmp = gfc_trans_dealloc_allocated (arg->expr->symtree->n.sym);
> + tmp = arg->expr->symtree->n.sym->backend_decl;
> + if (arg->expr->symtree->n.sym->attr.dummy)
> + tmp = build_fold_indirect_ref (tmp);
> + tmp = gfc_trans_dealloc_allocated (tmp);
> gfc_add_expr_to_block (&se->pre, tmp);
> }
>
> Index: gcc/fortran/trans-array.c
> ===================================================================
> --- gcc/fortran/trans-array.c (revision 112225)
> +++ gcc/fortran/trans-array.c (working copy)
> @@ -4308,20 +4308,16 @@ gfc_conv_array_parameter (gfc_se * se, g
> }
>
>
> -/* Generate code to deallocate the symbol 'sym', if it is allocated. */
> +/* Generate code to deallocate an array, if it is allocated. */
>
> tree
> -gfc_trans_dealloc_allocated (gfc_symbol * sym)
> +gfc_trans_dealloc_allocated (tree descriptor)
> {
> tree tmp;
> - tree descriptor;
> tree deallocate;
> stmtblock_t block;
>
> - gcc_assert (sym->attr.allocatable);
> -
> gfc_start_block (&block);
> - descriptor = sym->backend_decl;
> deallocate = gfc_array_deallocate (descriptor, null_pointer_node);
>
> tmp = gfc_conv_descriptor_data_get (descriptor);
> @@ -4396,7 +4392,7 @@ gfc_trans_deferred_array (gfc_symbol * s
> /* Allocatable arrays need to be freed when they go out of scope. */
> if (sym->attr.allocatable)
> {
> - tmp = gfc_trans_dealloc_allocated (sym);
> + tmp = gfc_trans_dealloc_allocated (sym->backend_decl);
> gfc_add_expr_to_block (&fnblock, tmp);
> }
>
> Index: gcc/fortran/trans-array.h
> ===================================================================
> --- gcc/fortran/trans-array.h (revision 112225)
> +++ gcc/fortran/trans-array.h (working copy)
> @@ -41,8 +41,8 @@ tree gfc_trans_auto_array_allocation (tr
> tree gfc_trans_dummy_array_bias (gfc_symbol *, tree, tree);
> /* Generate entry and exit code for g77 calling convention arrays. */
> tree gfc_trans_g77_array (gfc_symbol *, tree);
> -/* Generate code to deallocate the symbol 'sym', if it is allocated. */
> -tree gfc_trans_dealloc_allocated (gfc_symbol * sym);
> +/* Generate code to deallocate an array, if it is allocated. */
> +tree gfc_trans_dealloc_allocated (tree);
> /* Add initialization for deferred arrays. */
> tree gfc_trans_deferred_array (gfc_symbol *, tree);
> /* Generate an initializer for a static pointer or allocatable array. */
--
The striddo mz honom ok wnno sigher
ok giordo skadha mykin ok digher