[Patch, Fortran, F03] PR 40996: Allocatable Scalars
Daniel Kraft
d@domob.eu
Mon Aug 31 16:18:00 GMT 2009
Hi Janus,
Janus Weil wrote:
>>>> What is still missing is a check if the type in the
>>>> ALLOCATE stmt is compatible with the type of the allocate-object (i.e.
>>>> C624, see my test case).
>>>>
>>> Which type? For the intrinsic types, the checking of compatibility
>>> was in my original type.
>> Yeah, sure. This is about derived types, where you have two
>> possibilities AFAICS:
>> 1) If the object which is being allocated was declared with TYPE, the
>> ALLOCATE statement must have the same type (or omit it).
>> 2) If the object which was declared with CLASS, the ALLOCATE statement
>> may have any type which is a descendant of the original type.
>>
>> Btw: Do we have a function which checks if one type is an extension
>> (direct or indirect) of another, or do I have to invent this?
>
> Ok, I have implemented this now (updated patch attached).
I've not looked thoroughly at the whole patch, but here's a minor
comment to your new function (as I wrote in my other email):
+ while (t0 != t && t->attr.extension)
+ t = t->components->ts.u.derived;
I'd like it better if you used gfc_get_super_type here, because (that's
why I wrote that in the first place) in my opinion it is not that clear
without further knowledge what "t->components->ts.u.derived" should
really be (i.e. the super-type if there's any).
I think you can just do
t = gfc_get_super_type (t);
instead -- this seems much more understandable to me.
Otherwise thanks for your patch, I've not yet been able to try it, but
allocatable scalars are something very important to have, especially
when working towards polymorphism!
Cheers,
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri
More information about the Gcc-patches
mailing list