aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/defined_assignment_9.f90
blob: 50fa0070f18a0f30df19a7121328b7b177c17aed (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
35
36
37
38
39
40
41
42
43
44
45
! { dg-do run }
!
! PR fortran/57697
!
! Further test of typebound defined assignment
!
module m0
  implicit none
  type component
    integer :: i = 42
  contains
    procedure :: assign0
    generic :: assignment(=) => assign0
  end type
  type parent
    type(component) :: foo
  end type
contains
  elemental subroutine assign0(lhs,rhs)
    class(component), intent(INout) :: lhs
    class(component), intent(in) :: rhs
    lhs%i = 20
  end subroutine
end module

program main
  use m0
  implicit none
  block
    type(parent), allocatable :: left
    type(parent) :: right
!    print *, right%foo
    left = right
!    print *, left%foo
    if (left%foo%i /= 20) call abort()
  end block
  block
    type(parent), allocatable :: left(:)
    type(parent) :: right(5)
!    print *, right%foo
    left = right
!    print *, left%foo
    if (any (left%foo%i /= 20)) call abort()
  end block
end