xref: /llvm-project/flang/test/Semantics/definable02.f90 (revision d5285fef00f6c5a725a515118192dd117fc3c665)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
2
3! Ensure that FINAL subroutine can be called for array with vector-valued
4! subscript.
5
6module 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
29end module
30
31program 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  !PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f1'
40  x1([1]) = [t1()]
41  !PORTABILITY: Variable 'x2([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'f2'
42  x2([1]) = [t2()]
43  x3([1]) = [t3()] ! ok
44end
45