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