blob: 161d18f6df3d953a4c1aa51920454db309766649 [file] [log] [blame]
! { dg-do run }
! { dg-options "-fcoarray=lib -lcaf_single -fdump-tree-original" }
! { dg-additional-options "-latomic" { target libatomic_available } }
!
! Contributed by Ian Harvey <ian_harvey@bigpond.com>
! Extended by Andre Vehreschild <vehre@gcc.gnu.org>
! to test that coarray references in allocate work now
! PR fortran/67451
program main
implicit none
type foo
integer :: bar = 99
end type
class(foo), dimension(:), allocatable :: foobar[:]
class(foo), dimension(:), allocatable :: some_local_object
allocate(foobar(10)[*])
allocate(some_local_object, source=foobar)
if (.not. allocated(foobar)) STOP 1
if (lbound(foobar, 1) /= 1 .OR. ubound(foobar, 1) /= 10) STOP 2
if (.not. allocated(some_local_object)) STOP 3
if (any(some_local_object(:)%bar /= [99, 99, 99, 99, 99, 99, 99, 99, 99, 99])) STOP 4
deallocate(some_local_object)
deallocate(foobar)
end program
! Check that some_local_object is treated as rank-1 array.
! This failed beforehand, because the coarray attribute of the source=expression
! was propagated to some_local_object in the allocate.
! { dg-final { scan-tree-dump-not "some_local_object\._data\.dim\[1\]\.lbound" "original" } }