2018-09-30 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / transfer_class_2.f90
blobee48983d1bb1afcca9f212ea136333392f3d76d0
1 ! { dg-do run }
3 ! PR 54917: [OOP] TRANSFER on polymorphic variable causes ICE
5 ! Contributed by Janus Weil <janus@gcc.gnu.org>
7 module m
8 implicit none
9 type test_type
10 integer :: i = 0
11 contains
12 procedure :: ass
13 generic :: assignment(=) => ass
14 end type
15 contains
16 subroutine ass (a, b)
17 class(test_type), intent(out) :: a
18 class(test_type), intent(in) :: b
19 a%i = b%i
20 end subroutine
21 end module
24 program p
25 use m
26 implicit none
28 class(test_type), allocatable :: c
29 type(test_type) :: t
31 allocate(c)
33 ! (1) check CLASS-to-TYPE transfer
34 c%i=3
35 t = transfer(c, t)
36 if (t%i /= 3) STOP 1
38 ! (2) check TYPE-to-CLASS transfer
39 t%i=4
40 c = transfer(t, c)
41 if (c%i /= 4) STOP 2
43 end