Debian Codegraph @

gcc/testsuite/gfortran.dg/PR100120.f90

raw
1 ! { dg-do run }
2 !
3 ! Tests fix for PR100120
4 !
5
6 program main_p
7
8 implicit none
9
10 integer, parameter :: n = 11
11 integer, parameter :: m = 7
12 integer, parameter :: c = 63
13
14 type :: foo_t
15 integer :: i
16 end type foo_t
17
18 type, extends(foo_t) :: bar_t
19 integer :: j(n)
20 end type bar_t
21
22 integer, target :: ain(n)
23 character, target :: ac1(n)
24 character(len=m), target :: acn(n)
25 type(foo_t), target :: afd(n)
26 type(bar_t), target :: abd(n)
27 !
28 class(foo_t), pointer :: spf
29 class(foo_t), pointer :: apf(:)
30 class(bar_t), pointer :: spb
31 class(bar_t), pointer :: apb(:)
32 class(*), pointer :: spu
33 class(*), pointer :: apu(:)
34 integer :: i, j
35
36 ain = [(i, i=1,n)]
37 ac1 = [(achar(i+c), i=1,n)]
38 do i = 1, n
39 do j = 1, m
40 acn(i)(j:j) = achar(i*m+j+c-m)
41 end do
42 end do
43 afd%i = ain
44 abd%i = ain
45 do i = 1, n
46 abd(i)%j = 2*i*ain
47 end do
48 !
49 spf => afd(n)
50 if(.not.associated(spf)) stop 1
51 if(.not.associated(spf, afd(n))) stop 2
52 if(spf%i/=n) stop 3
53 apf => afd
54 if(.not.associated(apf)) stop 4
55 if(.not.associated(apf, afd)) stop 5
56 if(any(apf%i/=afd%i)) stop 6
57 !
58 spf => abd(n)
59 if(.not.associated(spf)) stop 7
60 if(.not.associated(spf, abd(n))) stop 8
61 if(spf%i/=n) stop 9
62 select type(spf)
63 type is(bar_t)
64 if(any(spf%j/=2*n*ain)) stop 10
65 class default
66 stop 11
67 end select
68 apf => abd
69 if(.not.associated(apf)) stop 12
70 if(.not.associated(apf, abd)) stop 13
71 if(any(apf%i/=abd%i)) stop 14
72 select type(apf)
73 type is(bar_t)
74 do i = 1, n
75 if(any(apf(i)%j/=2*i*ain)) stop 15
76 end do
77 class default
78 stop 16
79 end select
80 !
81 spb => abd(n)
82 if(.not.associated(spb)) stop 17
83 if(.not.associated(spb, abd(n))) stop 18
84 if(spb%i/=n) stop 19
85 if(any(spb%j/=2*n*ain)) stop 20
86 apb => abd
87 if(.not.associated(apb)) stop 21
88 if(.not.associated(apb, abd)) stop 22
89 if(any(apb%i/=abd%i)) stop 23
90 do i = 1, n
91 if(any(apb(i)%j/=2*i*ain)) stop 24
92 end do
93 !
94 spu => ain(n)
95 if(.not.associated(spu)) stop 25
96 if(.not.associated(spu, ain(n))) stop 26
97 select type(spu)
98 type is(integer)
99 if(spu/=n) stop 27
100 class default
101 stop 28
102 end select
103 apu => ain
104 if(.not.associated(apu)) stop 29
105 if(.not.associated(apu, ain)) stop 30
106 select type(apu)
107 type is(integer)
108 if(any(apu/=ain)) stop 31
109 class default
110 stop 32
111 end select
112 !
113 spu => ac1(n)
114 if(.not.associated(spu)) stop 33
115 if(.not.associated(spu, ac1(n))) stop 34
116 select type(spu)
117 type is(character(len=*))
118 if(len(spu)/=1) stop 35
119 if(spu/=ac1(n)) stop 36
120 class default
121 stop 37
122 end select
123 apu => ac1
124 if(.not.associated(apu)) stop 38
125 if(.not.associated(apu, ac1)) stop 39
126 select type(apu)
127 type is(character(len=*))
128 if(len(apu)/=1) stop 40
129 if(any(apu/=ac1)) stop 41
130 class default
131 stop 42
132 end select
133 !
134 spu => acn(n)
135 if(.not.associated(spu)) stop 43
136 if(.not.associated(spu, acn(n))) stop 44
137 select type(spu)
138 type is(character(len=*))
139 if(len(spu)/=m) stop 45
140 if(spu/=acn(n)) stop 46
141 class default
142 stop 47
143 end select
144 apu => acn
145 if(.not.associated(apu)) stop 48
146 if(.not.associated(apu, acn)) stop 49
147 select type(apu)
148 type is(character(len=*))
149 if(len(apu)/=m) stop 50
150 if(any(apu/=acn)) stop 51
151 class default
152 stop 52
153 end select
154 !
155 spu => afd(n)
156 if(.not.associated(spu)) stop 53
157 if(.not.associated(spu, afd(n))) stop 54
158 select type(spu)
159 type is(foo_t)
160 if(spu%i/=n) stop 55
161 class default
162 stop 56
163 end select
164 apu => afd
165 if(.not.associated(apu)) stop 57
166 if(.not.associated(apu, afd)) stop 58
167 select type(apu)
168 type is(foo_t)
169 if(any(apu%i/=afd%i)) stop 59
170 class default
171 stop 60
172 end select
173 !
174 spu => abd(n)
175 if(.not.associated(spu)) stop 61
176 if(.not.associated(spu, abd(n))) stop 62
177 select type(spu)
178 type is(bar_t)
179 if(spu%i/=n) stop 63
180 if(any(spu%j/=2*n*ain)) stop 64
181 class default
182 stop 65
183 end select
184 apu => abd
185 if(.not.associated(apu)) stop 66
186 if(.not.associated(apu, abd)) stop 67
187 select type(apu)
188 type is(bar_t)
189 if(any(apu%i/=abd%i)) stop 68
190 do i = 1, n
191 if(any(apu(i)%j/=2*i*ain)) stop 69
192 end do
193 class default
194 stop 70
195 end select
196 stop
197
198 end program main_p