This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, fortran] PR25532 ICE in gfc_conv_component_ref, at fortran/trans-expr.c:269
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>, Erik Edelmann <erik dot edelmann at iki dot fi>
- Cc: gfortran <fortran at gcc dot gnu dot org>, martin at mpa-garching dot mpg dot de
- Date: Wed, 28 Dec 2005 12:06:34 +0100
- Subject: [Patch, fortran] PR25532 ICE in gfc_conv_component_ref, at fortran/trans-expr.c:269
- References: <20051226213640.GA24382@acclab.helsinki.fi> <43B0D8D7.3030607@wanadoo.fr>
Erik and Tobi,
In the meantime, I will sort out a solution.
Now that the Christmas guests have all departed, I can unleash the patch
for the regression PR25532, as promised:-
The problem and its solution were relatively easy to sort out. The
derived type component of the nested derived type, in the submitted
testscase, was not being referenced in a contained procedure.
Therefore, its backend declaration was not being copied and the above
ICE resulted. The testsuite program is the reduced testcase contributed
by Erik Edelmann. I have checked that Martin Reineke's testcase
compiles correctly.
Regtested on FC3/Athlon1700.
I will commit tomorrow morning to trunk and 4.1, if there are no no
objections; the patch is nearly "obvious" and remedies an omission
without changing the principle of the original patch.
Paul
2005-12-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/25532
* trans-types.c (copy_dt_decls_ifequal): Copy declarations for
components of derived type components by recursing into
gfc_get_derived_type.
2005-12-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/25532
*gfortran.dg/host_used_types_1.f90: Check that host associated
derived type components of derived types are properly declared
in contained procedures.
Index: gcc/fortran/trans-types.c
===================================================================
*** gcc/fortran/trans-types.c (revision 109038)
--- gcc/fortran/trans-types.c (working copy)
*************** copy_dt_decls_ifequal (gfc_symbol *from,
*** 1414,1421 ****
to_cm = to->components;
from_cm = from->components;
for (; to_cm; to_cm = to_cm->next, from_cm = from_cm->next)
! to_cm->backend_decl = from_cm->backend_decl;
return 1;
}
--- 1414,1430 ----
to_cm = to->components;
from_cm = from->components;
+ /* Copy the component declarations. If a component is itself
+ a derived type, we need a copy of its component delarations.
+ This is done by recursing into gfc_get_derived_type. This
+ ensures that the component's component declarations have
+ been built. */
for (; to_cm; to_cm = to_cm->next, from_cm = from_cm->next)
! {
! to_cm->backend_decl = from_cm->backend_decl;
! if (from_cm->ts.type == BT_DERIVED)
! gfc_get_derived_type (to_cm->ts.derived);
! }
return 1;
}
! { dg-do compile }
! Tests the fix for PR25532, which was a regression introduced by
! the fix for PR20244.
!
! Contributed by Erik Edelmann <eedelman@gcc.gnu.org>
module ModelParams
implicit none
type ReionizationParams
real :: fraction
end type ReionizationParams
type CAMBparams
type(ReionizationParams) :: Reion
end type CAMBparams
type(CAMBparams) CP
end module ModelParams
module ThermoData
use ModelParams
implicit none
contains
subroutine inithermo()
use ModelParams
if (0 < CP%Reion%fraction) then
end if
end subroutine inithermo
! The bug expressed itself in this subroutine because the component type
! information was not being copied from the parent namespace.
subroutine SetTimeSteps
if (0 < CP%Reion%fraction) then
end if
end subroutine SetTimeSteps
end module ThermoData