| 1 |
!{ dg-do run } |
| 2 |
! |
| 3 |
! Check assignment works for derived types to memory referenced by pointer |
| 4 |
! Contributed by G. Steinmetz <[email protected]> |
| 5 |
|
| 6 |
program pr103391 |
| 7 |
type t |
| 8 |
character(1) :: c |
| 9 |
end type |
| 10 |
type t2 |
| 11 |
type(t), pointer :: a(:) |
| 12 |
end type |
| 13 |
|
| 14 |
type(t), target :: arr(2) |
| 15 |
type(t2) :: r |
| 16 |
|
| 17 |
arr = [t('a'), t('b')] |
| 18 |
|
| 19 |
r = f([arr]) |
| 20 |
if (any(r%a(:)%c /= ['a', 'b'])) stop 1 |
| 21 |
contains |
| 22 |
function f(x) |
| 23 |
class(t), intent(in), target :: x(:) |
| 24 |
type(t2) :: f |
| 25 |
allocate(f%a(size(x,1))) |
| 26 |
f%a = x |
| 27 |
end |
| 28 |
end |