aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/defined_assignment_3.f90
blob: 81a9841434fd49d3479b7ce733a9c30566e1faf1 (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
! { dg-do run }
! Test the fix for PR46897. defined_assignment_1.f90 checks that the PR
! testcases run correctly, this checks array components are OK.
!
module m0
  implicit none
  type component
    integer :: i = 0
  contains
    procedure :: assign0
    generic :: assignment(=)=>assign0
  end type
  type parent
    type(component) :: foo(2)
  end type
  type, extends(parent) :: child
    integer :: j
  end type
contains
  elemental subroutine assign0(lhs,rhs)
    class(component), intent(out) :: lhs
    class(component), intent(in) :: rhs
    lhs%i = 20
  end subroutine
end module


program main
  use m0
  implicit none
  type(child) :: infant0, infant1(2)

  infant0 = child([component(1),component(2)], 99)
  if (any (infant0%parent%foo%i .ne. [20, 20])) call abort

end