This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR 42647: Missed initialization/dealloc of allocatable scalar DT with allocatable component


>>> 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.

Attachment: pr42647_v4.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]