This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch/gfortran] PR18283
- From: Paul Thomas <paulthomas2 at wanadoo dot fr>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 30 May 2005 14:33:13 +0200
- Subject: [Patch/gfortran] PR18283
This patch cures pr18283 that arises because character scalar pointer
derived-type references cause an ICE in gfc_conv_string_parameter.
This, in turn, is caused by an incorrect dereference in
gfc_conv_component_ref.
Please excuse the diff relative to my own source. The pending patch for
pr18109 is from the same file.
Bubblestrapped and regtested on i686/RH9: OK to commit?
Regards
Paul T
2005-05-29 Paul Thomas <pault@gcc.gnu.org>
PR fortran/18283
* fortran/trans-expr.c (gfc_conv_component_ref): Remove the
dereference of scalar character pointer structure components.
2005-05-29 Paul Thomas <pault@gcc.gnu.org>
* gfortran.dg/char_pointer_comp_assign.f90:
Test character pointer structure component assignments.
! { dg-do run }
! This test the fix of PR18283, where assignments of scalar,
! character pointer components of derived types caused an ICE.
! It also checks that the array counterparts remain operational.
! Contributed by Paul Thomas pault@gcc.gnu.org
!
program char_pointer_comp_assign
implicit none
type :: dt
character (len=4), pointer :: scalar
character (len=4), pointer :: array(:)
end type dt
type (dt) :: a
character (len=4), target :: scalar_t ="abcd"
character (len=4), target :: array_t(2) = (/"abcd","efgh"/)
! Do assignments first
allocate (a%scalar, a%array(2))
a%scalar = scalar_t
if (a%scalar /= "abcd") call abort ()
a%array = array_t
if (any(a%array /= (/"abcd","efgh"/))) call abort ()
deallocate (a%scalar, a%array)
! Now do pointer assignments.
a%scalar => scalar_t
if (a%scalar /= "abcd") call abort ()
a%array => array_t
if (any(a%array /= (/"abcd","efgh"/))) call abort ()
end program char_pointer_comp_assign
*** /usr/windows/gcc-cvs/gcc/gcc/fortran/trans-expr.c 2005-05-30 14:25:55.000000000 +0200
--- /usr/windows/gfortran/character/trans-expr.c 2005-05-30 14:26:43.000000000 +0200
*************** gfc_conv_component_ref (gfc_se * se, gfc
*** 281,287 ****
se->string_length = tmp;
}
! if (c->pointer && c->dimension == 0)
se->expr = gfc_build_indirect_ref (se->expr);
}
--- 281,287 ----
se->string_length = tmp;
}
! if (c->pointer && c->dimension == 0 && c->ts.type != BT_CHARACTER)
se->expr = gfc_build_indirect_ref (se->expr);
}