summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/class_allocate_5.f90
blob: 592161ef5196fa9a6cd06b81b70b7fb203d44871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
! { dg-do run }
!
! PR fortran/45451
!
! Contributed by Salvatore Filippone and Janus Weil
!
! Check that ALLOCATE with SOURCE= does a deep copy.
!
program bug23
  implicit none

  type  :: psb_base_sparse_mat
    integer, allocatable :: irp(:)
  end type psb_base_sparse_mat

  class(psb_base_sparse_mat), allocatable  :: a 
  type(psb_base_sparse_mat) :: acsr

  allocate(acsr%irp(4)) 
  acsr%irp(1:4) = (/1,3,4,5/)

  write(*,*) acsr%irp(:)

  allocate(a,source=acsr)

  write(*,*) a%irp(:)

  call move_alloc(acsr%irp, a%irp)

  write(*,*) a%irp(:)

  if (any (a%irp /= [1,3,4,5])) call abort()
end program bug23