@@ -209,6 +209,8 @@ module m2
209
209
type :: impureFinal
210
210
contains
211
211
final :: impureSub
212
+ final :: impureSubRank1
213
+ final :: impureSubRank2
212
214
end type
213
215
214
216
type :: pureFinal
@@ -222,28 +224,37 @@ impure subroutine impureSub(x)
222
224
type (impureFinal), intent (in ) :: x
223
225
end subroutine
224
226
227
+ impure subroutine impureSubRank1 (x )
228
+ type (impureFinal), intent (in ) :: x(:)
229
+ end subroutine
230
+
231
+ impure subroutine impureSubRank2 (x )
232
+ type (impureFinal), intent (in ) :: x(:,:)
233
+ end subroutine
234
+
225
235
pure subroutine pureSub (x )
226
236
type (pureFinal), intent (in ) :: x
227
237
end subroutine
228
238
229
239
subroutine s4 ()
230
240
type (impureFinal), allocatable :: ifVar, ifvar1
241
+ type (impureFinal), allocatable :: ifArr1(:), ifArr2(:,:)
242
+ type (impureFinal) :: if0
231
243
type (pureFinal), allocatable :: pfVar
232
244
allocate (ifVar)
233
245
allocate (ifVar1)
234
246
allocate (pfVar)
247
+ allocate (ifArr1(5 ), ifArr2(5 ,5 ))
235
248
236
249
! OK for an ordinary DO loop
237
250
do i = 1 ,10
238
251
if (i .eq. 1 ) deallocate (ifVar)
239
252
end do
240
253
241
254
! OK to invoke a PURE FINAL procedure in a DO CONCURRENT
242
- ! This case does not work currently because the compiler's test for
243
- ! HasImpureFinal() in .../lib/Semantics/tools.cc doesn't work correctly
244
- ! do concurrent (i = 1:10)
245
- ! if (i .eq. 1) deallocate(pfVar)
246
- ! end do
255
+ do concurrent (i = 1 :10 )
256
+ if (i .eq. 1 ) deallocate (pfVar)
257
+ end do
247
258
248
259
! Error to invoke an IMPURE FINAL procedure in a DO CONCURRENT
249
260
do concurrent (i = 1 :10 )
@@ -271,6 +282,34 @@ subroutine s4()
271
282
ifvar = ifvar1
272
283
end if
273
284
end do
285
+
286
+ do concurrent (i = 1 :5 )
287
+ if (i .eq. 1 ) then
288
+ ! ERROR: Deallocation of an entity with an IMPURE FINAL procedure 'impuresub' caused by assignment not allowed in DO CONCURRENT
289
+ ifArr1(i) = if0
290
+ end if
291
+ end do
292
+
293
+ do concurrent (i = 1 :5 )
294
+ if (i .eq. 1 ) then
295
+ ! ERROR: Deallocation of an entity with an IMPURE FINAL procedure 'impuresubrank1' caused by assignment not allowed in DO CONCURRENT
296
+ ifArr1 = if0
297
+ end if
298
+ end do
299
+
300
+ do concurrent (i = 1 :5 )
301
+ if (i .eq. 1 ) then
302
+ ! ERROR: Deallocation of an entity with an IMPURE FINAL procedure 'impuresubrank1' caused by assignment not allowed in DO CONCURRENT
303
+ ifArr2(i,:) = if0
304
+ end if
305
+ end do
306
+
307
+ do concurrent (i = 1 :5 )
308
+ if (i .eq. 1 ) then
309
+ ! ERROR: Deallocation of an entity with an IMPURE FINAL procedure 'impuresubrank2' caused by assignment not allowed in DO CONCURRENT
310
+ ifArr2(:,:) = if0
311
+ end if
312
+ end do
274
313
end subroutine s4
275
314
276
315
end module m2
0 commit comments