From: Paul Thomas Date: Sun, 15 Mar 2015 09:13:03 +0000 (+0000) Subject: re PR fortran/65024 ([OOP] unlimited polymorphic pointer structure not built when... X-Git-Tag: releases/gcc-4.8.5~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea9e814fdb2adfd6ef08dea0456c3570aede73e5;p=thirdparty%2Fgcc.git re PR fortran/65024 ([OOP] unlimited polymorphic pointer structure not built when it should be) 2015-03-15 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-15 Paul Thomas PR fortran/65024 * gfortran.dg/unlimited_polymorphic_23.f90: New test From-SVN: r221440 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9f8c177339f7..0a4a9f940342 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2015-03-15 Paul Thomas + + Backport from mainline + 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-12 Mikael Morin PR fortran/60898 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 850ed834a58b..472059b0b6f9 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1553,10 +1553,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 6e720d820f41..73c6b9e6a072 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-15 Paul Thomas + + Backport from mainline + PR fortran/65024 + * gfortran.dg/unlimited_polymorphic_23.f90: New test + 2015-03-12 Mikael Morin PR fortran/60898 @@ -630,7 +636,7 @@ Backported from mainline 2013-09-17 Cong Hou - * gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product + * gcc.dg/vect/vect-reduc-dot-s16c.c: Add a test case with dot product on two arrays with short and int types. This should not be recognized as a dot product pattern. 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 000000000000..27eff3105327 --- /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