1! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
2! Tests for C1128:
3! A variable-name that appears in a LOCAL or LOCAL_INIT locality-spec shall not
4! have the ALLOCATABLE; INTENT (IN); or OPTIONAL attribute; shall not be of
5! finalizable type; shall not be a nonpointer polymorphic dummy argument; and
6! shall not be a coarray or an assumed-size array.
7
8subroutine s1()
9! Cannot have ALLOCATABLE variable in a locality spec
10  integer, allocatable :: k
11!ERROR: ALLOCATABLE variable 'k' not allowed in a locality-spec
12  do concurrent(i=1:5) local(k)
13  end do
14end subroutine s1
15
16subroutine s2(arg)
17! Cannot have a dummy OPTIONAL in a locality spec
18  integer, optional :: arg
19!ERROR: OPTIONAL argument 'arg' not allowed in a locality-spec
20  do concurrent(i=1:5) local(arg)
21  end do
22end subroutine s2
23
24subroutine s3(arg)
25! This is OK
26  real :: arg
27  do concurrent(i=1:5) local(arg)
28  end do
29end subroutine s3
30
31subroutine s4(arg)
32! Cannot have a dummy INTENT(IN) in a locality spec
33  real, intent(in) :: arg
34!ERROR: INTENT IN argument 'arg' not allowed in a locality-spec
35  do concurrent(i=1:5) local(arg)
36  end do
37end subroutine s4
38
39subroutine s5()
40! Cannot have a variable of a finalizable type in a locality spec
41  type t1
42    integer :: i
43  contains
44    final :: f
45  end type t1
46
47  type(t1) :: var
48
49!ERROR: Finalizable variable 'var' not allowed in a locality-spec
50  do concurrent(i=1:5) local(var)
51  end do
52
53contains
54  subroutine f(x)
55    type(t1) :: x
56  end subroutine f
57end subroutine s5
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