http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49466

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #8 from janus at gcc dot gnu.org 2011-06-27 17:33:19 UTC ---
(In reply to comment #7)
> This is due to revision 165973:


... and fixed by a partial revert of this commit (see below), which is free of
testsuite regressions. Will commit as obvious soon (unfortunately too late for
the 4.6.1 release).


Index: gcc/testsuite/gfortran.dg/allocatable_scalar_9.f90
===================================================================
--- gcc/testsuite/gfortran.dg/allocatable_scalar_9.f90    (revision 175536)
+++ gcc/testsuite/gfortran.dg/allocatable_scalar_9.f90    (working copy)
@@ -49,7 +49,7 @@ if(allocated(na3%b3)) call abort()
 if(allocated(na4%b4)) call abort()
 end

-! { dg-final { scan-tree-dump-times "__builtin_free" 32 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_free" 38 "original" } }
 ! { dg-final { cleanup-tree-dump "original" } }

 ! { dg-final { cleanup-modules "m" } }
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c    (revision 175536)
+++ gcc/fortran/trans-array.c    (working copy)
@@ -6682,18 +6682,22 @@ structure_alloc_comps (gfc_symbol * der_type, tree
       switch (purpose)
     {
     case DEALLOCATE_ALLOC_COMP:
+      if (cmp_has_alloc_comps && !c->attr.pointer)
+        {
+          /* Do not deallocate the components of ultimate pointer
+         components.  */
+          comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
+                      decl, cdecl, NULL_TREE);
+          rank = c->as ? c->as->rank : 0;
+          tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE,
+                       rank, purpose);
+          gfc_add_expr_to_block (&fnblock, tmp);
+        }
+
       if (c->attr.allocatable && c->attr.dimension)
         {
           comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
                       decl, cdecl, NULL_TREE);
-          if (cmp_has_alloc_comps && !c->attr.pointer)
-        {
-          /* Do not deallocate the components of ultimate pointer
-             components.  */
-          tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE,
-                           c->as->rank, purpose);
-          gfc_add_expr_to_block (&fnblock, tmp);
-        }
           tmp = gfc_trans_dealloc_allocated (comp);
           gfc_add_expr_to_block (&fnblock, tmp);
         }

Reply via email to