aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/defined_assignment_11.f90
blob: ec297d5492a8318921a28ced0bd6f09e4c222511 (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
! { dg-do run }
!
! PR fortran/57697
!
! Further test of typebound defined assignment
!
module m0
  implicit none
  type :: component
    integer :: i = 42
    integer, allocatable :: b
  contains
    procedure :: assign0
    generic :: assignment(=) => assign0
  end type
  type, extends(component) :: comp2
    real :: aa
  end type comp2
  type parent
    type(component) :: foo
    real :: cc
  end type
  type p2
    type(parent) :: x
  end type p2
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
  type(p2), allocatable :: left
  type(p2) :: right
!  print *, right%x%foo%i
  left = right
!  print *, left%x%foo%i
  if (left%x%foo%i /= 20) call abort()
end