This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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,fortran] Allocatable dummy-fix


:ADDPATCH fortran:

While working on the allocatable components stuff, I stumbled
across a bug for the allocatable dummy arguments:  If the actual
argument to a INTENT(OUT) allocatable dummy argument is itself a
dummy argument of the caller, we get an ICE:

erik:~$ cat test.f90
subroutine foo(x)
    real, allocatable, intent(inout) :: x(:)

    call bar(x)

contains

    subroutine bar(x)
        real, allocatable, intent(out) :: x(:)
    end subroutine bar

end subroutine foo
erik:~$ gfortran test.f90
test.f90: In function 'foo':
test.f90:4: internal compiler error: in
gfc_conv_descriptor_data_addr, at fortran/trans-array.c:186
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


The attached patch fixes this problem.  The solution is to, in
trans-expr.c (gfc_conv_function_call) in the code to deallocate
INTENT(OUT) arguments prior to a procedure call, use an indirect
reference through sym->backend_decl rather than sym->backend_decl
itself.

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.  This might make the
patch a little more complicated than it would have to be to fix
this bug, but I need this for the allocatable components, so I
decided to do it like this rather that doing something that I
would have to change later otherwise.

Regtested on Linux/x86.  Ok for trunk?


        Erik



2006-03-20  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-03-20  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.

Attachment: allocatable_dummy.diff-4
Description: Text document


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