[Patch, Fortran, OOP] PR 44541: wrong code for polymorphic variable with INTENT(OUT)/Alloc w/ MOLD

Janus Weil janus@gcc.gnu.org
Wed Sep 1 21:01:00 GMT 2010


>> I don't see what you mean. The intention here was to check the
>> 'referenced' attribute only for non-dummies, but anyway ...
>
> Sorry, I misread that part. I think your patch makes sense - but for some
> reason it does not seem to be required.
>
> For my example, the value is set via: resolve_fl_variable ->
> resolve_fl_variable_derived, which contains:
>
>  /* Assign default initializer.  */
>  if (!(sym->value || sym->attr.pointer || sym->attr.allocatable)
> && (!no_init_flag || sym->attr.intent == INTENT_OUT))
>    {
>      sym->value = gfc_default_initializer (&sym->ts);
>    }
>
> Thus, I really wonder whether the resolve_symbol's version is used at all.
>
>> +  if (sym->ts.type == BT_CLASS&&  sym->ns == gfc_current_ns
>> +&&  sym->attr.dummy&&  sym->attr.intent == INTENT_OUT
>> +&&  !sym->attr.pointer&&  !sym->attr.allocatable)
>> +    apply_default_init (sym);
>> +
>>    /* If this symbol has a type-spec, check it.  */
>>    if (sym->attr.flavor == FL_VARIABLE || sym->attr.flavor == FL_PARAMETER
>>        || (sym->attr.flavor == FL_PROCEDURE&&  sym->attr.function))
>
> OK - though one could think of plugging into the resolve_fl_variable or
> resolve_fl_variable_derived code.

I have now committed the patch as r163744 (with the small addition
that one needs to set the 'referenced' attribute of the symbol if it
is unused otherwise).

Maybe I'll do some research whether 'apply_default_init' is needed at
all for BT_DERIVED, if I find some time on the weekend.

Cheers,
Janus



More information about the Gcc-patches mailing list