[Patch, Fortran] PR 42647: Missed initialization/dealloc of allocatable scalar DT with allocatable component
Janus Weil
janus@gcc.gnu.org
Wed Oct 13 13:05:00 GMT 2010
>>> This seems to work fine at -O0, but the patch currently still has two
>>> regressions at -O1 and higher:
>>> * allocatable_scalar_9.f90
>>> * class_19.f03
>>>
>>> allocatable_scalar_9.f90:29:0: error: statement makes a memory store,
>>> but has no VDEFS
>>> a4_193.b4.data = 0B;
>>> allocatable_scalar_9.f90:29:0: internal compiler error: verify_ssa failed
>>
>> Well, the reason that it only fails with -O1 is simple: The check is guarded
>> by "optimization > 0".
>>
>> Regarding the issue itself: Try in gfc_auto_deallocate:
>>
>> tmp = build_fold_indirect_ref_loc (input_location, pointer);
>> tmp = gfc_deallocate_alloc_comp (sym->ts.u.derived, tmp,
>> sym->as ? sym->as->rank : 0);
>
>
> Great, that seems to fix it. Thanks a lot!
>
> I will check the updated patch with another testsuite run. Ok for
> trunk if that passes?
Self-review: Three things were still missing:
1) Auto-deallocation of CLASS components.
2) Auto-deallocation of "sub-components", i.e. stuff like a%b%c.
3) Test cases.
First of all I renamed 'gfc_auto_deallocate' to
'gfc_deallocate_scalar' (which is a more suitable name).
For (1) I simply added another piece in 'gfc_deallocate_scalar' which
handles CLASS components.
For (2) I modified 'gfc_deallocate_scalar' in such a way that it can
not only handle allocatable scalar variables, but also allocatable
scalar components, so that I can call it from 'structure_alloc_comps'.
As test cases I'm using the two present ones in the testsuite that
were failing earlier (allocatable_scalar_9.f90 and class_19.f03). They
contain all relevant cases and I simply added checking for the
appropriate number of '__builtin_free' calls in the dumps.
The patch was regtested successfully on x86_64-unknown-linux-gnu. Ok for trunk?
Cheers,
Janus
2010-10-13 Janus Weil <janus@gcc.gnu.org>
PR fortran/42647
* trans.h (gfc_deallocate_scalar): New prototype.
* trans.c (gfc_deallocate_scalar): New function for deallocation of
allocatable scalars.
* trans-decl.c (gfc_trans_deferred_vars): Call it here ...
* trans-array.c (structure_alloc_comps): ... and here.
2010-10-13 Janus Weil <janus@gcc.gnu.org>
PR fortran/42647
* gfortran.dg/allocatable_scalar_9.f90: Extended.
* gfortran.dg/class_19.f03: Extended.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr42647_v4.diff
Type: application/octet-stream
Size: 6585 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20101013/6e185572/attachment.obj>
More information about the Fortran
mailing list