summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/class_to_type_3.f03
blob: 2db2be82e23a08a43031222cb427a64bbe7b7456 (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
! { dg-do run }
! Tests the fix for pr63553 in which the class container was being
! assigned to derived types, rather than the data.
!
! Contributed by <patnel97269-gfortran@yahoo.fr>
!
program toto
  implicit none
  type mother
    integer :: i
  end type mother
  type,extends(mother) :: child
  end type child

  call comment1
  call comment2

contains
  subroutine comment1
    type(mother) :: tm
    class(mother),allocatable :: cm

    allocate (cm)
    cm%i = 77
    tm = cm
    if (tm%i .ne. cm%i) STOP 1
  end subroutine

  subroutine comment2
    class(mother),allocatable :: cm,cm2

    allocate(cm)
    allocate(child::cm2)
    cm%i=10
    select type (cm2)
       type is (child)
         cm2%mother=cm
    end select
    if (cm2%i .ne. cm%i) STOP 2
  end subroutine
end program