| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/121342 |
| 4 |
! The polymorphic function result as actual argument used to force the loop |
| 5 |
! bounds around the elemental call, altering access to the other arrays. |
| 6 |
|
| 7 |
program p |
| 8 |
implicit none |
| 9 |
type :: t |
| 10 |
integer :: i |
| 11 |
end type |
| 12 |
type :: u |
| 13 |
integer :: i, a |
| 14 |
end type |
| 15 |
type(u) :: accum(5) |
| 16 |
integer :: a(3:7), k |
| 17 |
a = [ (k*k, k=1,5) ] |
| 18 |
call s(accum, f(), a) |
| 19 |
! print *, accum%i |
| 20 |
! print *, accum%a |
| 21 |
if (any(accum%i /= accum%a)) error stop 1 |
| 22 |
contains |
| 23 |
elemental subroutine s(l, c, a) |
| 24 |
type(u) , intent(out) :: l |
| 25 |
class(t) , intent(in) :: c |
| 26 |
integer , intent(in) :: a |
| 27 |
l%i = c%i |
| 28 |
l%a = a |
| 29 |
end subroutine |
| 30 |
function f() |
| 31 |
class(t), allocatable :: f(:) |
| 32 |
allocate(f(-1:3)) |
| 33 |
f%i = [ (k*k, k=1,5) ] |
| 34 |
end function |
| 35 |
end program |