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]

Re: [patch,fortran] PR 16136: ALLOCATABLE dummy arguments


On Mon, Mar 06, 2006 at 04:34:30PM +0100, THOMAS Paul Richard 169137 wrote:
> First of all, well done on making a start on this important extension.
> What you have done works fine.  However, the patch is incomplete in two
> aspects, the first quite important, and I suggest that it(they) be sorted
> out before proceeding further to function results and allocatable components:
> 
> (i) When a procedure is invoked, any allocated allocatable object that is
> an actual argument associated with an INTENT(OUT) allocatable dummy argument
> is deallocated; any allocated allocatable object that is a subobject of an
> actual argument associated with an INTENT(OUT) dummy argument is deallocated.
> (6.3.3.1).

Argh! That was it! I had a strong feeling that I had forgotten
something important. The only thing I can say to my defense is that
http://www.nag.co.uk/nagware/NP/doc/tr.asp doesn't mention this
(I browsed through that document before I posted the patch to see
that I hadn't forgotten anything).

> Please find attached a patch to fix this and a revised version of
> allocatable_dummy_1.f90.  I suggest that this block of code be broken out
> into a new function that can be referenced from gfc_conv_function_call and
> trans-array.c(gfc_trans_deferred_array) from where it has been borrowed.
> This function will be needed for allocatable components too. 

Ok, attached is a patch that implements Paul's suggestion, and
his revised version of allocatable_dummy_1.f90.  Regression
tested on trunk, on Linux/x86.  Ok to commit?


> (ii) The second problem concerns the correct association of pointers and
> allocatable arrays, where the actual argument is host or use associated
> as well. I have not checked the F95 standard yet but F2003 requires that
> the dummy argument take precedence.

You are right about this.  However, I feel that it can wait for
later.


        Erik



2005-03-06  Paul Thomas  <pault@gcc.gnu.org>
            Erik Edelmann  <eedelman@gcc.gnu.org>

        * trans-array.c (gfc_trans_dealloc_allocated): New function.
        (gfc_trans_deferred_array): Use it, instead of inline code.
        * trans-array.h: Prototype for gfc_trans_dealloc_allocated().
        * trans-expr.c (gfc_conv_function_call): Deallocate allocated
        ALLOCATABLE, INTENT(OUT) arguments upon procedure entry.


2005-03-06  Paul Thomas  <pault@gcc.gnu.org>

        gfortran.dg/allocatable_dummy_1.f90: Take into account that
        INTENT(OUT) arguments shall be deallocated upon procedure entry.


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