| 1 |
! { dg-do run } |
| 2 |
! PR fortran/66089 - used to ICE and, after that ICE was fixed, |
| 3 |
! gave wrong results. |
| 4 |
type :: t |
| 5 |
integer :: c |
| 6 |
end type t |
| 7 |
|
| 8 |
class(t), dimension(:), allocatable :: b,c |
| 9 |
|
| 10 |
allocate (b(5), source=t(7)) |
| 11 |
allocate(c(5), source=t(13)) |
| 12 |
c = plus(c(1), b) |
| 13 |
if (any(c%c /= 20)) stop 1 |
| 14 |
c = t(13) |
| 15 |
c = plus(b, c(1)) |
| 16 |
if (any(c%c /= 20)) stop 2 |
| 17 |
contains |
| 18 |
|
| 19 |
elemental function plus(lhs, rhs) |
| 20 |
class(t), intent(in) :: lhs, rhs |
| 21 |
type(t) :: plus |
| 22 |
plus%c = lhs%c + rhs%c |
| 23 |
end function plus |
| 24 |
|
| 25 |
end |