[Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer

Paul Richard Thomas paul.richard.thomas@gmail.com
Thu Feb 26 06:01:00 GMT 2015


Dear All,

This patch has something of a band aid flavour about it. However, the
more I look at it the more I like it and it cannot do any harm. In any
case, I spent a silly amount of time trying to understand why this
component fails to get its backend_decl in the usual way and failed.
That it is specific to unlimited polymorphic components and only
appears when 'bug' precedes 'next' were, in principle, giveaways that
didn't do it for me.

Bootstraps and regtests on x86_64/FC21 - OK for trunk and 4.9?

Paul

2015-02-26  Paul Thomas  <pault@gcc.gnu.org>

    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-02-26  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/65024
    * gfortran.dg/unlimited_polymorphic_23.f90: New test
-------------- next part --------------
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c	(revision 220653)
--- gcc/fortran/trans-expr.c	(working copy)
*************** gfc_conv_component_ref (gfc_se * se, gfc
*** 1930,1939 ****
  
    c = ref->u.c.component;
  
!   gcc_assert (c->backend_decl);
  
    field = c->backend_decl;
!   gcc_assert (TREE_CODE (field) == FIELD_DECL);
    decl = se->expr;
  
    /* Components can correspond to fields of different containing
--- 1930,1941 ----
  
    c = ref->u.c.component;
  
!   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 (field && TREE_CODE (field) == FIELD_DECL);
    decl = se->expr;
  
    /* Components can correspond to fields of different containing
Index: gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90
===================================================================
*** gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/unlimited_polymorphic_23.f90	(working copy)
***************
*** 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  <matt@gneilson.plus.com>
+ !
+ 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


More information about the Gcc-patches mailing list