This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR29699 - ICE in trans-decl.c
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Nov 2006 11:29:02 +0100
- Subject: [Patch, fortran] PR29699 - ICE in trans-decl.c
:ADDPATCH fortran:
The patch, including testcase, is already posted on Bugzilla:
http://gcc.gnu.org/bugzilla/attachment.cgi?id=12552&action=view
The problem arises with automatic arrays of derived types with
allocatable components. It comprises three parts:
(i) Initialization of these objects is done at the end of
resolve_symbol by the generation of some extra code. If the array was
not referenced, the ICE would occur, as in the subject line. This is
fixed by requiring that the initialization only be done if the object
is referenced.
(ii) If one then references the object, as in the testcase, the
gimplifier wobbles because it is fed a pointer to an array rather than
a descriptor or an array in trans-array.c(structure_alloc_comps).
This comes about because the backend declaration to an automatic array
is a pointer to the array. This is cured by detecting that the
declaration is POINTER_TYPE_P and using an indirect reference.
(iii) Finally, the nulling of the components was being done before the
array was allocated and the dealloaction before the components were
deallocated, with obvious consequences. The fix is to change the
order of these actions in trans-decl.c(gfc_trans_deferred_vars).
With these changes, automatic arrays of derived types with allocatable
components become operational.
Please ignore the part in comment #3 in the PR about deallocation of
allocatable components overnight; whilst deallocation is being
overdone a bit, this has no direct connection with this patch.
Regested on x86_ia64/FC5 and amd64/Cygwin_NT - OK for trunk and 4.2?
Paul
2006-11-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29699
* trans-array.c (structure_alloc_comps): Detect pointers to
arrays and use indirect reference to declaration.
* resolve.c (resolve_fl_variable): Tidy up condition.
(resolve_symbol): The same and only add initialization code if
the symbol is referenced.
* trans-decl.c (gfc_trans_deferred_vars): Call gfc_trans_
deferred_array before gfc_trans_auto_array_allocation.
2006-11-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29699
* gfortran.dg/alloc_comp_auto_array_1.f90: New test.
.