[PATCH, Fortran] Derived type finalization: Already somewhat useable...
Daniel Kraft
d@domob.eu
Sun Jul 6 09:10:00 GMT 2008
Ralf Wildenhues wrote:
> Hello Daniel,
>
> A quick typo-only review:
Thanks Ralf,
fixed and hopefully I'll spell those right next time ;)
Daniel
> * Daniel Kraft wrote on Fri, Jul 04, 2008 at 05:47:57PM CEST:
>> 2008-06-22 Daniel Kraft <d@domob.eu>
>>
>
>> * resolve.c (generated_finalizers): New global static needed for
>> derived type finalization.
>> (finalize_intent_out_args), (put_finalizers_before): New helper
>> function for finalization.
>> (resolve_function): Call finalize_inten_out_args.
>
> finalize_intent_out_args
>
>> (gfc_resolve_call): Ditto and made public, renamed from reslve_call.
>
> resolve_call
>
>> (resolve_deallocate_expr): Finalize expr before it is deallocated.
>> (resolve_allocate_deallocate): Call reslve_deallocate_expr with new
>
> resolve_deallocate_expr
>
>> locus argument.
>
>> (finalize_symbols_tail): New private variabes used for finalization.
>
> variables
>
>> (find_finalizable_symbols), (call_finalizing_procedures_at),
>> (call_finalizing_procedures): New methods used for finalization of
>> symbols when going out of scope.
>> (resolve_codes): Initiate finalization of symbols at the end of scope.
>
>> --- gcc/fortran/gfortran.h (revision 137369)
>> +++ gcc/fortran/gfortran.h (working copy)
>> @@ -1952,16 +1952,24 @@ typedef struct iterator_stack
>> iterator_stack;
>> extern iterator_stack *iter_stack;
>>
>> -
>> /* Node in the linked list used for storing finalizer procedures. */
>>
>> typedef struct gfc_finalizer
>> {
>> struct gfc_finalizer* next;
>> - gfc_symbol* procedure;
>> locus where; /* Where the FINAL declaration occured. */
>
> Has been there before, but would still be good to fix: occurred.
>
>> --- gcc/fortran/expr.c (revision 137369)
>> +++ gcc/fortran/expr.c (working copy)
>
>> +/* Helper function to generate a gfc_expr from another one and adding one more
>> + reference to the ref-chain. This reference itself is not filled, only a
>> + pointer to it returned and the caller must ensure it is intialized
>
> initialized
>
>> + properly. */
>> +/* XXX: Make this a global, general purpose function? */
>> +
>> +static gfc_expr*
>> +generate_reference_expr (gfc_expr* expr, gfc_ref** reftail, ref_type type)
>
>> --- gcc/fortran/resolve.c (revision 137369)
>> +++ gcc/fortran/resolve.c (working copy)
>
>> @@ -6258,6 +6359,12 @@ resolve_code (gfc_code *code, gfc_namesp
>>
>> if (resolve_ordinary_assign (code, ns))
>> goto call;
>> + else
>> + /* Finalize LHS of assignment before executing it. Do only if
>> + not an error occured during the above resolution. */
>
> occurred
>
>> + if (code->expr)
>> + gfc_finalize_expr (code->expr, false, &generated_finalizers,
>> + code->loc);
>
>> @@ -9285,6 +9408,119 @@ resolve_types (gfc_namespace *ns)
>
>> + /* If we are inside the main PROGRAM, *only* ALLOCATABLE entities are
>> + finalized because the standard explicitelly requests variables there not
>
> explicitly
>
>> + to be finalized but ALLOCATABLE entities are auto-deallocated there. */
>> + if (finalize_only_allocatable && !sym->attr.allocatable)
>> + return;
>
> Cheers,
> Ralf
>
More information about the Gcc-patches
mailing list