This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch,gfortran] PR 19929: Deallocation of pointer components of derived type arrays


:ADDPATCH fortran:

Here is a patch for PR 19929.

The problem is that for the deallocate statement in code like
this

    type :: t
        integer, pointer :: p
    end type t
    type(t) :: a(1)

    ...

    deallocate(a(1)%p)

we try to generate code for deallocating an array.  This happens
because in gfc_trans_deallocate()/trans-stmt.c, we check if the
object to be deallocated is an array by looking at
expr->symtree->n.sym->attr.dimension.  This is wrong, because
expr->symtree->n.sym is the variable 'a' (which is an array),
not it's component 'p' (which is not an array).  I changed
the code to look at expr->rank instead.

*strapped and reg.tested on mainline and 4.0, Linux/x86. Please
commit if OK.


        Erik


2005-09-19  Erik Edelmann  <erik.edelmann@iki.fi>

        PR fortran/19929
        * trans-stmt.c (gfc_trans_deallocate): Check if the 
          object to be deallocated is an array by looking at 
          expr->rank instead of expr->symtree->n.sym->attr.dimension.


2005-09-19  Erik Edelmann  <erik.edelmann@iki.fi>

        PR fortran/19929
        * gfortran.dg/der_ptr_component_1.f90: New test.

Attachment: 19929.diff
Description: Text document

Attachment: der_ptr_component_1.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]