This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran, OOP] PR 57562: ICE due to extended derived type with PARAMETER attribute


Hi all,

the attached patch fixes a problem with PARAMETER variables of
extended derived type: When resolving component references to the such
variables, we have to find the right component of the corresponding
structure constructor expression, which is done by the function
'find_component_ref'.

This function could not handle extended derived types, and so that is
what the patch does. For extended derived types, the first component
always represents the parent type. We have to iterate through the
whole inheritance chain, in order to check in which parent type the
desired component is located and fetch the corresponding constructor
component.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2015-01-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/57562
    * expr.c (find_component_ref): Deal with extended types.

2015-01-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/57562
    * gfortran.dg/extends_16.f90: New.

Attachment: pr57562.diff
Description: Text document

! { dg-do run }
!
! PR 57562: [OOP] ICE due to extended derived type with PARAMETER attribute
!
! Contributed by <helvio.vairinhos@gmail.com>

   type :: Parent
      integer :: member1 = 0
   end type

   type, extends(Parent) :: Child
      integer :: member2 = 0
   end type

   type(Child), parameter :: object = Child(23, 42)

   if (object%member1 /= 23) call abort
   if (object%member2 /= 42) call abort

end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]