Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / definable02.f90
blobab20b6701a669fab184581ced583759679c70f6d
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! Ensure that FINAL subroutine can be called for array with vector-valued
4 ! subscript.
6 module m
7 type t1
8 contains
9 final :: f1
10 end type
11 type t2
12 contains
13 final :: f2
14 end type
15 type t3
16 contains
17 final :: f3
18 end type
19 contains
20 subroutine f1(x)
21 type(t1), intent(in out) :: x(:)
22 end subroutine
23 subroutine f2(x)
24 type(t2), intent(in out) :: x(..)
25 end subroutine
26 impure elemental subroutine f3(x)
27 type(t3), intent(in out) :: x
28 end subroutine
29 end module
31 program test
32 use m
33 type(t1) x1(1)
34 type(t2) x2(1)
35 type(t3) x3(1)
36 x1(:) = [t1()] ! ok
37 x2(:) = [t2()] ! ok
38 x3(:) = [t3()] ! ok
39 !ERROR: Left-hand side of assignment is not definable
40 !BECAUSE: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and cannot be finalized by non-elemental subroutine 'f1'
41 x1([1]) = [t1()]
42 !ERROR: Left-hand side of assignment is not definable
43 !BECAUSE: Variable 'x2([INTEGER(8)::1_8])' has a vector subscript and cannot be finalized by non-elemental subroutine 'f2'
44 x2([1]) = [t2()]
45 x3([1]) = [t3()] ! ok
46 end