Plugins: Add label-text.h to CPPLIB_H so it will be installed [PR115288]
[official-gcc.git] / gcc / testsuite / gfortran.dg / class_to_type_3.f03
blob2db2be82e23a08a43031222cb427a64bbe7b7456
1 ! { dg-do run }
2 ! Tests the fix for pr63553 in which the class container was being
3 ! assigned to derived types, rather than the data.
5 ! Contributed by <patnel97269-gfortran@yahoo.fr>
7 program toto
8   implicit none
9   type mother
10     integer :: i
11   end type mother
12   type,extends(mother) :: child
13   end type child
15   call comment1
16   call comment2
18 contains
19   subroutine comment1
20     type(mother) :: tm
21     class(mother),allocatable :: cm
23     allocate (cm)
24     cm%i = 77
25     tm = cm
26     if (tm%i .ne. cm%i) STOP 1
27   end subroutine
29   subroutine comment2
30     class(mother),allocatable :: cm,cm2
32     allocate(cm)
33     allocate(child::cm2)
34     cm%i=10
35     select type (cm2)
36        type is (child)
37          cm2%mother=cm
38     end select
39     if (cm2%i .ne. cm%i) STOP 2
40   end subroutine
41 end program