1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! Tests for C1128:
4! A variable-name that appears in a LOCAL or LOCAL_INIT locality-spec shall not
5! have the ALLOCATABLE; INTENT (IN); or OPTIONAL attribute; shall not be of
6! finalizable type; shall not be a nonpointer polymorphic dummy argument; and
7! shall not be a coarray or an assumed-size array.
8
9subroutine s1()
10! Cannot have ALLOCATABLE variable in a locality spec
11  integer, allocatable :: k
12!ERROR: ALLOCATABLE variable 'k' not allowed in a locality-spec
13  do concurrent(i=1:5) local(k)
14  end do
15end subroutine s1
16
17subroutine s2(arg)
18! Cannot have a dummy OPTIONAL in a locality spec
19  integer, optional :: arg
20!ERROR: OPTIONAL argument 'arg' not allowed in a locality-spec
21  do concurrent(i=1:5) local(arg)
22  end do
23end subroutine s2
24
25subroutine s3(arg)
26! This is OK
27  real :: arg
28  do concurrent(i=1:5) local(arg)
29  end do
30end subroutine s3
31
32subroutine s4(arg)
33! Cannot have a dummy INTENT(IN) in a locality spec
34  real, intent(in) :: arg
35!ERROR: INTENT IN argument 'arg' not allowed in a locality-spec
36  do concurrent(i=1:5) local(arg)
37  end do
38end subroutine s4
39
40module m
41! Cannot have a variable of a finalizable type in a locality spec
42  type t1
43    integer :: i
44  contains
45    final :: f
46  end type t1
47 contains
48  subroutine s5()
49    type(t1) :: var
50    !ERROR: Finalizable variable 'var' not allowed in a locality-spec
51    do concurrent(i=1:5) local(var)
52    end do
53  end subroutine s5
54  subroutine f(x)
55    type(t1) :: x
56  end subroutine f
57end module m
58
59subroutine s6
60! Cannot have a nonpointer polymorphic dummy argument in a locality spec
61  type :: t
62    integer :: field
63  end type t
64contains
65  subroutine s(x, y)
66    class(t), pointer :: x
67    class(t) :: y
68
69! This is allowed
70    do concurrent(i=1:5) local(x)
71    end do
72
73! This is not allowed
74!ERROR: Nonpointer polymorphic argument 'y' not allowed in a locality-spec
75    do concurrent(i=1:5) local(y)
76    end do
77  end subroutine s
78end subroutine s6
79
80subroutine s7()
81! Cannot have a coarray
82  integer, codimension[*] :: coarray_var
83!ERROR: Coarray 'coarray_var' not allowed in a locality-spec
84  do concurrent(i=1:5) local(coarray_var)
85  end do
86end subroutine s7
87
88subroutine s8(arg)
89! Cannot have an assumed size array
90  integer, dimension(*) :: arg
91!ERROR: Assumed size array 'arg' not allowed in a locality-spec
92  do concurrent(i=1:5) local(arg)
93  end do
94end subroutine s8
95