annotate gcc/testsuite/gfortran.dg/move_alloc_10.f90 @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do run }
kono
parents:
diff changeset
2 !
kono
parents:
diff changeset
3 ! Test move_alloc for polymorphic scalars
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! The following checks that a move_alloc from
kono
parents:
diff changeset
6 ! a TYPE to a CLASS works
kono
parents:
diff changeset
7 !
kono
parents:
diff changeset
8 module myalloc
kono
parents:
diff changeset
9 implicit none
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 type :: base_type
kono
parents:
diff changeset
12 integer :: i =2
kono
parents:
diff changeset
13 end type base_type
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 type, extends(base_type) :: extended_type
kono
parents:
diff changeset
16 integer :: j = 77
kono
parents:
diff changeset
17 end type extended_type
kono
parents:
diff changeset
18 contains
kono
parents:
diff changeset
19 subroutine myallocate (a)
kono
parents:
diff changeset
20 class(base_type), allocatable, intent(inout) :: a
kono
parents:
diff changeset
21 type(extended_type), allocatable :: tmp
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 allocate (tmp)
kono
parents:
diff changeset
24
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
25 if (tmp%i /= 2 .or. tmp%j /= 77) STOP 1
111
kono
parents:
diff changeset
26 tmp%i = 5
kono
parents:
diff changeset
27 tmp%j = 88
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 select type(a)
kono
parents:
diff changeset
30 type is(base_type)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
31 if (a%i /= -44) STOP 2
111
kono
parents:
diff changeset
32 a%i = -99
kono
parents:
diff changeset
33 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 STOP 3
111
kono
parents:
diff changeset
35 end select
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 call move_alloc (from=tmp, to=a)
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 select type(a)
kono
parents:
diff changeset
40 type is(extended_type)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 if (a%i /= 5) STOP 4
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 if (a%j /= 88) STOP 5
111
kono
parents:
diff changeset
43 a%i = 123
kono
parents:
diff changeset
44 a%j = 9498
kono
parents:
diff changeset
45 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
46 STOP 6
111
kono
parents:
diff changeset
47 end select
kono
parents:
diff changeset
48
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
49 if (allocated (tmp)) STOP 7
111
kono
parents:
diff changeset
50 end subroutine myallocate
kono
parents:
diff changeset
51 end module myalloc
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 program main
kono
parents:
diff changeset
54 use myalloc
kono
parents:
diff changeset
55 implicit none
kono
parents:
diff changeset
56 class(base_type), allocatable :: a
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 allocate (a)
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 select type(a)
kono
parents:
diff changeset
61 type is(base_type)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 if (a%i /= 2) STOP 8
111
kono
parents:
diff changeset
63 a%i = -44
kono
parents:
diff changeset
64 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
65 STOP 9
111
kono
parents:
diff changeset
66 end select
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 call myallocate (a)
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 select type(a)
kono
parents:
diff changeset
71 type is(extended_type)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
72 if (a%i /= 123) STOP 10
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 if (a%j /= 9498) STOP 11
111
kono
parents:
diff changeset
74 class default
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75 STOP 12
111
kono
parents:
diff changeset
76 end select
kono
parents:
diff changeset
77 end program main