*ping* - Re: [Patch, Fortran] Enable FINALization/poly dealloc for allocatables

Tobias Burnus burnus@net-b.de
Tue Jun 4 10:06:00 GMT 2013


Mikael Morin wrote:
>> +++ b/gcc/fortran/trans-decl.c
>> @@ -3872,7 +3892,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
>>   	      /* Deallocate when leaving the scope. Nullifying is not
>>   		 needed.  */
>> -	      if (!sym->attr.result && !sym->attr.dummy)
>> +	      if (!sym->attr.result && !sym->attr.dummy
>> +		  && !sym->ns->proc_name->attr.is_main_program)
> No check for !sym->attr.save here?

The code is in a big if block which has:

           if (!sym->attr.save && gfc_option.flag_max_stack_var_size != 0)
             {

> There are several places through the patch where we check whether a
> variable needs end of scope automatic deallocation. Might be worth
> factoring the checks to a common predicate.

Probably yes. One other case which needs some refactoring* is allocate: 
We currently immediately distinguish between arrays and scalars - and 
only the scalar code handles "allocate(character(len=5) :: str)" - the 
array code duplicates part of the code, but not fully.

> The patch is OK in any case; thanks.

Thanks for the review!

Tobias

* To my surprise, the word "refactor"/"refactoring" does not exist in 
Marriam Webbster, nor in the Oxford Dictionary of English (or 
oxfordreference.com). On the other hand, it has a wikipedia page, 
thousands of book and article titles, dating back to the 60s and 
seemingly it is more widely used since the 1990s/2000s.



More information about the Fortran mailing list