[Patch, Fortran] Coarrays: Don't (free)/alloc LHS coarray components on assignment

Tejas Belagod tbelagod@arm.com
Tue Jul 16 16:17:00 GMT 2013


Tobias Burnus wrote:
> Tobias Burnus wrote:
>> With coarrays, allocation/deallocation of coarrays requires a 
>> synchronization with all other images. Thus, the standard restricts 
>> changing the allocation status to: ALLOCATE and DEALLOCATE statements 
>> plus end-of-scope deallocation.
>>
>> In particular, with intrinsic assignment the allocation status does 
>> not change. Hence, there is no realloc on assignment. But also (this 
>> patch!) no deallocation/allocation of allocatable components during 
>> intrinsic assignment of derived types. [This implies that the LHS 
>> componet has to have the same allocation status, shape, 
>> type-parameters and actual type as the RHS.]
>>
>> The patch additionally checks whether end-of-scope deallocation of 
>> coarrays properly calls the deregister function (it did/does).
>>
>> Build and regtested on x86-64-gnu-linux.
>> OK for the trunk?
> 
> Update: I forgot to copy the back the address of the allocated CAF - 
> which lead to an unwanted address sharing between the RHS and LHS.
> 
> Note: structure_alloc_comps also contains bits from 
> http://gcc.gnu.org/ml/fortran/2013-06/msg00131.html
> 
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
> 
> Tobias
> 

2013-06-26  Tobias Burnus  <burnus@net-b.de>

	* trans-array.h (gfc_deallocate_alloc_comp_no_caf,
	gfc_reassign_alloc_comp_caf): New prototype.
	* trans-array.c (enum): Add DEALLOCATE_ALLOC_COMP_NO_CAF
	and COPY_ALLOC_COMP_CAF.
	(structure_alloc_comps): Handle it.
	(gfc_reassign_alloc_comp_caf,
	gfc_deallocate_alloc_comp_no_caf): New function.
	(gfc_alloc_allocatable_for_assignment): Call it.
	* trans-expr.c (gfc_trans_scalar_assign,
	gfc_trans_arrayfunc_assign, gfc_trans_assignment_1): Ditto.
	* parse.c (parse_derived): Correctly set coarray_comp.
	* resolve.c (resolve_symbol): Improve error wording.

2013-06-26  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/coarray_lib_realloc_1.f90: New.
	* gfortran.dg/coarray/lib_realloc_1.f90: New.
	* gfortran.dg/coarray_6.f90: Add dg-error.

Hi,

I observed that this patch causes an ICE with one of the fortran tests. I've 
filed a bug report here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57912.

Thanks,
Tejas Belagod.
ARM.



More information about the Fortran mailing list