Hi all, here is a rather simple fix for a problem with the pointer assignment of an unlimited polymorphic variable. The patch regtests cleanly on x86_64-unknown-linux-gnu.
Firstly, I would like to commit to trunk, of course. Ok? Secondly, the bug reporter asked me (privately) for the possibility of backporting the fix to 4.8 (which is the only release supporting unlimited polymorphism so far). It is important for his code at http://sourceforge.net/projects/permix/. Although the bug is not a regression, I would tend to support this request (due to the simplicity and low risk of the patch). So, is the patch ok for 4.8 also? [Btw, I plan to do some more cleanup related to the vtab generation on trunk soon, but I tried to keep the present patch as simple as possible, in order to keep it safe for backporting.] Cheers, Janus 2013-12-14 Janus Weil <ja...@gcc.gnu.org> PR fortran/59493 * class.c (gfc_find_intrinsic_vtab): Handle BT_CLASS. 2013-12-14 Janus Weil <ja...@gcc.gnu.org> PR fortran/59493 * gfortran.dg/unlimited_polymorphic_15.f90: New.
Index: gcc/fortran/class.c =================================================================== --- gcc/fortran/class.c (revision 205982) +++ gcc/fortran/class.c (working copy) @@ -2424,7 +2424,7 @@ gfc_find_intrinsic_vtab (gfc_typespec *ts) return NULL; /* Sometimes the typespec is passed from a single call. */ - if (ts->type == BT_DERIVED) + if (ts->type == BT_DERIVED || ts->type == BT_CLASS) return gfc_find_derived_vtab (ts->u.derived); /* Find the top-level namespace. */
! { dg-do compile } ! ! PR 59493: [OOP] ICE: Segfault on Class(*) pointer association ! ! Contributed by Hossein Talebi <talebi.hoss...@gmail.com> implicit none type ty_mytype1 end type class(ty_mytype1), allocatable, target:: cla1 class(*), pointer :: ptr ptr => cla1 end