Dynamic dispatch of class typebound procedures ~ methods
Janus Weil
janus@gcc.gnu.org
Mon Sep 28 09:44:00 GMT 2009
Hi Paul,
> Nonetheless, I have stared at symbol.c(gfc_type_compatible) and the
> standard and have come to the conclusion that the former is not quite
> correct. At very least, it does not do the right thing, I believe,
> when both ts1 and ts2 are CLASSes (It winds up comparing the class
> containers, rather than the declared types. More importantly, here,
> what should happen when the actual argument is a class, whose value is
> an extension of the declared type of a class formal argument?
well, I think although this case is not treated explicitly, it should
still work correctly. If both are classes, it is checked whether the
class container of ts2 is an extension of the type of ts1 (which is
the case if the type of ts2 is an extension of the type of ts1, since
the class container is an extension of the the type of ts2.
So I believe it should be correct, or do I miss something?
> It does
> not treat this case at all (- because formal and actual are the wrong
> way round in the call from gfc_compare_types?).
in compare_parameter you find
gfc_compare_types (&formal->ts, &actual->ts)
while gfc_compare_types itself calls
gfc_type_compatible (ts1, ts2)
so I think the ordering of the formal vs. actual argument should be ok
(of course gfc_type_compatible must be asymmetic in its arguments.
Cheers,
Janus
More information about the Fortran
mailing list