1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3!C1129
4!A variable that is referenced by the scalar-mask-expr of a
5!concurrent-header or by any concurrent-limit or concurrent-step in that
6!concurrent-header shall not appear in a LOCAL locality-spec in the same DO
7!CONCURRENT statement.
8
9subroutine s1()
10
11!ERROR: 'i' is already declared in this scoping unit
12  do concurrent (i=1:10) local(i)
13  end do
14end subroutine s1
15
16subroutine s2()
17!ERROR: 'i' is already declared in this scoping unit
18  do concurrent (i=1:10) local_init(i)
19  end do
20end subroutine s2
21
22subroutine s4()
23!ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
24  do concurrent (j=i:10) local(i)
25  end do
26end subroutine s4
27
28subroutine s5()
29  !OK because the locality-spec is local_init
30  do concurrent (j=i:10) local_init(i)
31  end do
32end subroutine s5
33
34subroutine s6()
35  !OK because the locality-spec is shared
36  do concurrent (j=i:10) shared(i)
37  end do
38end subroutine s6
39
40subroutine s7()
41!ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
42  do concurrent (j=1:i) local(i)
43  end do
44end subroutine s7
45
46subroutine s8()
47  !OK because the locality-spec is local_init
48  do concurrent (j=1:i) local_init(i)
49  end do
50end subroutine s8
51
52subroutine s9()
53  !OK because the locality-spec is shared
54  do concurrent (j=1:i) shared(i)
55  end do
56end subroutine s9
57
58subroutine s10()
59!ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
60  do concurrent (j=1:10:i) local(i)
61  end do
62end subroutine s10
63
64subroutine s11()
65  !OK because the locality-spec is local_init
66  do concurrent (j=1:10:i) local_init(i)
67  end do
68end subroutine s11
69
70subroutine s12()
71  !OK because the locality-spec is shared
72  do concurrent (j=1:10:i) shared(i)
73  end do
74end subroutine s12
75
76subroutine s13()
77  ! Test construct-association, in this case, established by the "shared"
78  integer :: ivar
79  associate (avar => ivar)
80!ERROR: DO CONCURRENT expression references variable 'ivar' in LOCAL locality-spec
81    do concurrent (j=1:10:avar) local(avar)
82    end do
83  end associate
84end subroutine s13
85
86module m1
87  integer :: mvar
88end module m1
89subroutine s14()
90  ! Test use-association, in this case, established by the "shared"
91  use m1
92
93!ERROR: DO CONCURRENT expression references variable 'mvar' in LOCAL locality-spec
94  do concurrent (k=mvar:10) local(mvar)
95  end do
96end subroutine s14
97
98subroutine s15()
99  ! Test host-association, in this case, established by the "shared"
100  ! locality-spec
101  ivar = 3
102  do concurrent (j=ivar:10) shared(ivar)
103!ERROR: DO CONCURRENT expression references variable 'ivar' in LOCAL locality-spec
104    do concurrent (k=ivar:10) local(ivar)
105    end do
106  end do
107end subroutine s15
108