[Patch, Fortran] Calling type-bound procedures
Daniel Kraft
d@domob.eu
Fri Aug 29 06:10:00 GMT 2008
Tobias Burnus wrote:
> Hi Daniel,
>
>> this is the cleaned-up version of my patch to allow for calling
>> type-bound procedures posted yesterday including a ChangeLog.
>
> As a small thing: I think one should update dump-parse-tree.c; I think
> everyone tends to forget it and it is almost never used.
I thought about this but if that's ok will include this in the
documentation-fix following up.
> I like your patch. However - thanks to NAG f95 - I just realized that we
> currently cannot implement PASS in a standard conforming matter. The
> reason is:
>
> C453 The passed-object dummy argument shall be a scalar, nonpointer,
> nonallocatable dummy data object with the same declared type as
> the type being defined; all of its length type parameters
> shall be assumed; it shall be polymorphic (5.1.1.2) if and only
> if the type being defined is extensible.
>
> The problem with PASS for all type-bound procedures and for procedure-
> pointer components in non-SEQUENCE, non-BIND(C) procedures is the
> following: The type needs to by polymorphic, i.e. instead of
>
> TYPE(mytype) :: dummy_arg
> one needs
> CLASS(mytype):: dummy_arg
>
> Thinking about it, it makes sense: Unless the procedure is overwritten,
> the type%inherited_proc() won't work. (I have not checked what happends
> currently.)
That's what I stumbled across and mentioned on IRC, too, after testing
with NAG :)
> The big question is now how to handle this? For proc pointer comps with
> SEQUENCE and BIND(C) [assuming PASS is allowed for them, I have not
> checked] the current machinary can be used, but for an ordinary,
> extensible type? Shall we abort in this case with "Sorry, not
> implemented"? Too bad that Paul has not managed to recreate his CLASS
> patch :-(
>
> Somehow type-bound procedures without PASS loose a lot of their
> usefulness. Except for this point I think the patch is OK.
From my point of view, the best solution would be to let it as it is
now and emit maybe a warning for type-bound procedures with PASS about
this problem; to fix it once polymorphic entities are available will of
course be easy, just change the check during resolution time for the
passed-object dummy argument. Or maybe do a GNU Fortran extension until
then, possibly together with the warning so people know their code will
break when this is fixed.
Alternatively, I think we could print not-implemented for each PASS and
leave the patch otherwise as it is to allow for this change easily at a
later point.
What's your opinion on this?
Daniel
--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou
More information about the Gcc-patches
mailing list