From 6cb7d18f626255743e566b3b9a79810afa98b014 Mon Sep 17 00:00:00 2001 From: pault Date: Tue, 10 Mar 2015 19:39:05 +0000 Subject: [PATCH] 2015-03-10 Paul Thomas PR fortran/65024 * trans-expr.c (gfc_conv_component_ref): If the component backend declaration is missing and the derived type symbol is available in the reference, call gfc_build_derived_type. 2015-03-10 Paul Thomas PR fortran/65024 * gfortran.dg/unlimited_polymorphic_23.f90: New test git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221334 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++ gcc/fortran/trans-expr.c | 6 ++-- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/unlimited_polymorphic_23.f90 | 35 ++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ae6865e..b9f34a3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-03-10 Paul Thomas + + PR fortran/65024 + * trans-expr.c (gfc_conv_component_ref): If the component + backend declaration is missing and the derived type symbol is + available in the reference, call gfc_build_derived_type. + 2015-03-10 Alessandro Fanfarillo Tobias Burnus diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index db04b30..353d012 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1930,10 +1930,12 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) c = ref->u.c.component; - gcc_assert (c->backend_decl); + if (c->backend_decl == NULL_TREE + && ref->u.c.sym != NULL) + gfc_get_derived_type (ref->u.c.sym); field = c->backend_decl; - gcc_assert (TREE_CODE (field) == FIELD_DECL); + gcc_assert (field && TREE_CODE (field) == FIELD_DECL); decl = se->expr; /* Components can correspond to fields of different containing diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0daa10..5acef58 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-10 Paul Thomas + + PR fortran/65024 + * gfortran.dg/unlimited_polymorphic_23.f90: New test + 2015-03-10 Jakub Jelinek PR c++/65127 diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 new file mode 100644 index 0000000..27eff31 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90 @@ -0,0 +1,35 @@ +! {dg-do run } +! +! Test the fix for PR65024, in which the structure for the 'info' +! component of type 'T' was not being converted into TREE_SSA and +! so caused an ICE in trans-expr.c:gfc_conv_component_ref. +! +! Reported by +! +MODULE X + TYPE T + CLASS(*), pointer :: info + END TYPE +END MODULE + +PROGRAM P + call bug +CONTAINS + SUBROUTINE BUG + USE X + CLASS(T), pointer :: e + integer, target :: i = 42 + allocate(e) + e%info => NULL () ! used to ICE + if (.not.associated(e%info)) e%info => i ! used to ICE + select type (z => e%info) + type is (integer) + if (z .ne.i) call abort + end select + END SUBROUTINE + + SUBROUTINE NEXT + USE X + CLASS (T), pointer :: e + END SUBROUTINE +END -- 2.7.4