public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer
@ 2015-02-26  6:01 Paul Richard Thomas
  2015-03-08 11:11 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2015-02-26  6:01 UTC (permalink / raw)
  To: Janus Weil, gcc-patches, fortran

[-- Attachment #1: Type: text/plain, Size: 896 bytes --]

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

[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 1997 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer
  2015-02-26  6:01 [Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer Paul Richard Thomas
@ 2015-03-08 11:11 ` Paul Richard Thomas
  2015-03-08 11:37   ` FX
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2015-03-08 11:11 UTC (permalink / raw)
  To: Janus Weil, gcc-patches, fortran

ping!!!

On 26 February 2015 at 06:33, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> 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



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer
  2015-03-08 11:11 ` Paul Richard Thomas
@ 2015-03-08 11:37   ` FX
  0 siblings, 0 replies; 3+ messages in thread
From: FX @ 2015-03-08 11:37 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: Janus Weil, gcc-patches, fortran

>> 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.

Well, it fixes things and seems safe, so let’s do it.

OK to commit.

FX

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-08 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26  6:01 [Patch, fortran] PR65024 - [4.9/5 Regression] [OOP] ICE concerning unlimited polymorphic pointer Paul Richard Thomas
2015-03-08 11:11 ` Paul Richard Thomas
2015-03-08 11:37   ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).