[PATCH, Fortran] Extend F2003 structure constructor support

Daniel Kraft d@domob.eu
Thu May 15 14:58:00 GMT 2008


Daniel Kraft wrote:
>  >I think the following program is valid since no private components are
>  >accessed by the (useless) constructor:
>  >
>  >  module m
>  >    type t
>  >      private
>  >      integer :: i = 5
>  >    end type t
>  >  end module m
>  >
>  >  use m
>  >  type(t) :: x = t()
>  >  end
>  >
>  >It is currently rejected with:
>  >  Error: Structure constructor for 't' at (1) has PRIVATE access
> 
> As discussed with FX, this was a misunderstanding of myself about what 
> the private above should mean.  Fixed (and changed error message to "All 
> components of 't' are PRIVATE").
> 
> Also added a test (to structure_constructor_8.f03) for calling a 
> constructor of a PRIVATE type, although this already worked.
> 
>  >> I'm not sure about where to insert gfc_notify_std calls; maybe F2003
>  >> notify-std when an argument with name is parsed and possibly also 
>  >>when
>  >> a default value is inserted? Or is that allowed for -std=f95, too? I
>  >> will then of course also add tests for these messages as appropriate.
>  >
>  >Well, Fortran 95 allows:
>  >"4.4.4 Construction of derived-type values [...]
>  > R431  structure-constructor  is  type-name ( expr-list )
>  >       The sequence of expressions in a structure component values
>  >       that shall agree in number and order with the components of
>  >       the derived type."
>  >
>  >Thus your checks for applying a default value ond for the presence of a
>  >keyword= sound reasonable.
> 
> Inserted these calls and a test case to verify it works.
> 
> Revised patch and ChangeLog attached; all I did change was inserting the 
> notify_std-calls and the code to handle the all-components-private part 
> as well as some minor extensions to the tests.

Sorry, forgot to add:  Testsuite succeeds for me on GNU/Linux-x86-32.

Daniel



More information about the Fortran mailing list