view gcc/testsuite/gfortran.dg/class_allocate_13.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { dg-do run }
!
! PR 54784: [4.7/4.8 Regression] [OOP] wrong code in polymorphic allocation with SOURCE
!
! Contributed by Jeremy Kozdon <jkozdon@gmail.com>

program bug
  implicit none

  type :: block
    real, allocatable :: fields
  end type

  type :: list
    class(block),allocatable :: B
  end type

  type :: domain
    type(list),dimension(2) :: L
  end type

  type(domain) :: d
  type(block) :: b1

  allocate(b1%fields,source=5.)
  
  allocate(d%L(2)%B,source=b1)           ! wrong code
  
  if (d%L(2)%B%fields/=5.) STOP 1

end program