[patch, fortran] Allocatable function results.

Paul Thomas paulthomas2@wanadoo.fr
Thu Mar 9 17:50:00 GMT 2006


Erik

:REVIEWMAIL:

>Here's a patch to implement allocatable function results.  It
>does the following:
>
Great!

>
>* What did I forget this time :-) ?
>
I do not think that you forgot anything:

(i) The standard(12.2.2) requires that the interface be explicit in any 
scoping unit in which the function is referenced.  I have extended the 
first test case to test the various explicit interfaces.  Testing the 
case of an implicit interface requires that global symbols for 
procedures carry argument and result type and kind information.  I have 
this already on my list of TODOs.
(ii)  In principle, the standard requires that the function result be 
allocated on return.  I have attached a patch to trans-expr.c that does 
this.  It is, however, of limited utility.  The segfaults that result 
from assigning to unallocated arrays mask most of the cases where this 
might act.  Perhaps this addition should be part of array bounds checking?

>testsuite/
>2006-03-08  Erik Edelmann  <eedelman@gcc.gnu.org>
>
>        * gfortran.dg/allocatable_function_1.f90: New.
>        * gfortran.dg/allocatable_function_2.f90: New.
>
I have extended allocatable_function_1.f90, as described above.  It 
probably needs cleaning up a bit but it does a belt-and-braces job on 
checking that allocatable results work in evry situation that I could 
think of.

I have also appended a compile only version of this test that uses the 
option -fdump-tree-original and counts that the allocatable result 
arrays are freed the right number of times. It's possibly neurotic but 
it's worth the check IMHO.  It does actually run under DejaGnu with this 
check in place, so the two could be combined.

On the patch itself: could you please use tabs.  I know that fortran is 
meant to be a tab free zone but the compiler (mostly) uses them.

The patch regtests fine on Athlon/FC3.

Subject to these remarks/modifications - OK to commit.

If you need any help to implement the allocatable components, I am game; 
just let me know.

Many thanks.

Paul



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: trans-expr.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060309/624baebe/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: allocatable_function_1c.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060309/624baebe/attachment.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: allocatable_function_1.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060309/624baebe/attachment-0001.f90>


More information about the Fortran mailing list