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]

Re: [PATCH, fortran] Interoperability with C int128_t types


Daniel Kraft wrote:
> I've attached a patch and its ChangeLog that makes
> gfc_match_structure_constructor interpret named arguments for
> structure constructors and use default initializers for components not
> explicitelly given a value.

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

It is also rejected by NAG f95 and g95; however, I believe the only
restriction is the following:

  C488 (R457) The type name and all components of the type for
              which a component-spec appears shall be accessible in
              the scoping unit containing the structure constructor.

And C488 does not apply.


> 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.

Otherwise it looks OK. I like the test cases :-)

Tobias


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