]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans-array.c (gfc_trans_dealloc_allocated): Take a tree representation of the array...
authorErik Edelmann <eedelman@gcc.gnu.org>
Sun, 2 Apr 2006 17:00:39 +0000 (17:00 +0000)
committerErik Edelmann <eedelman@gcc.gnu.org>
Sun, 2 Apr 2006 17:00:39 +0000 (17:00 +0000)
2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>

        * trans-array.c (gfc_trans_dealloc_allocated): Take a
        tree representation of the array to be deallocated as argument
        instead of its gfc_symbol.
        (gfc_trans_deferred_array): Update call to
        gfc_trans_dealloc_allocated.
        * trans-array.h (gfc_trans_dealloc_allocated): Update prototype.
        * trans-expr.c (gfc_conv_function_call): Update call to
        gfc_trans_dealloc_allocated, get indirect reference to dummy
        arguments.

2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>

        * gfortran.dg/allocatable_dummy_1.f90: Also check that allocatable
        dummy arguments work when the actual argument is itself a dummy
        argument of the caller.

From-SVN: r112625

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-array.h
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90

index c7aa2a79a55abfc9107b5aa9fb259be1a09a0edb..3743cbdbd1b5b69dc76d421e5c482fca5da1aa7a 100644 (file)
@@ -1,3 +1,16 @@
+2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       * trans-array.c (gfc_trans_dealloc_allocated): Take a
+       tree representation of the array to be deallocated as argument
+       instead of its gfc_symbol.
+       (gfc_trans_deferred_array): Update call to
+       gfc_trans_dealloc_allocated.
+       * trans-array.h (gfc_trans_dealloc_allocated): Update
+       prototype.
+       * trans-expr.c (gfc_conv_function_call): Update call to
+       gfc_trans_dealloc_allocated, get indirect reference to dummy
+       arguments.
+
 2006-04-01  Roger Sayle  <roger@eyesopen.com>
 
        PR fortran/25270
index 7136d1efbd6f98918145b1b02bc0ec909bed0432..5ebec62772b3009c49b646680478a2218dbbbb50 100644 (file)
@@ -4308,20 +4308,16 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77)
 }
 
 
-/* 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 * sym, tree body)
   /* 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 bc7cab54db32c01d5f23c3fa0261a2442ec76eb0..6f57429ae3c7feb61f51bf69b5b787d91f4986a7 100644 (file)
@@ -41,8 +41,8 @@ tree gfc_trans_auto_array_allocation (tree, gfc_symbol *, tree);
 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.  */
index 783583caac87276bb3abf29500e2c5936c7bd505..94921bc1138eb182910ee8edca7442a9344522d2 100644 (file)
@@ -1920,7 +1920,10 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
               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 a10cb4edfc4f7b2ed6aabe41c45df12cfe3c83ed..66badc350ce9bd86235326f7175c0d1f10df4992 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-02  Erik Edelmann  <eedelman@gcc.gnu.org>
+
+       * gfortran.dg/allocatable_dummy_1.f90: Also check that allocatable
+       dummy arguments work when the actual argument is itself a dummy
+       argument of the caller.
+
 2006-04-01  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR libfortran/24685
index bfa9ced010f117c5eb9a1cc762ad1717bc3f20df..9aba8b8fc6dc10791df56475ad4fc269d612ce04 100644 (file)
@@ -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