Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / dosemantics09.f90
blob9e6bca2cca24c9ae78273f3ca16897cb0c67a9dc
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.
8 subroutine s1()
10 !ERROR: 'i' is already declared in this scoping unit
11 do concurrent (i=1:10) local(i)
12 end do
13 end subroutine s1
15 subroutine s2()
16 !ERROR: 'i' is already declared in this scoping unit
17 do concurrent (i=1:10) local_init(i)
18 end do
19 end subroutine s2
21 subroutine s4()
22 !ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
23 do concurrent (j=i:10) local(i)
24 end do
25 end subroutine s4
27 subroutine s5()
28 !OK because the locality-spec is local_init
29 do concurrent (j=i:10) local_init(i)
30 end do
31 end subroutine s5
33 subroutine s6()
34 !OK because the locality-spec is shared
35 do concurrent (j=i:10) shared(i)
36 end do
37 end subroutine s6
39 subroutine s7()
40 !ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
41 do concurrent (j=1:i) local(i)
42 end do
43 end subroutine s7
45 subroutine s8()
46 !OK because the locality-spec is local_init
47 do concurrent (j=1:i) local_init(i)
48 end do
49 end subroutine s8
51 subroutine s9()
52 !OK because the locality-spec is shared
53 do concurrent (j=1:i) shared(i)
54 end do
55 end subroutine s9
57 subroutine 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
61 end subroutine s10
63 subroutine s11()
64 !OK because the locality-spec is local_init
65 do concurrent (j=1:10:i) local_init(i)
66 end do
67 end subroutine s11
69 subroutine s12()
70 !OK because the locality-spec is shared
71 do concurrent (j=1:10:i) shared(i)
72 end do
73 end subroutine s12
75 subroutine 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
83 end subroutine s13
85 module m1
86 integer :: mvar
87 end module m1
88 subroutine s14()
89 ! Test use-association, in this case, established by the "shared"
90 use m1
92 !ERROR: DO CONCURRENT expression references variable 'mvar' in LOCAL locality-spec
93 do concurrent (k=mvar:10) local(mvar)
94 end do
95 end subroutine s14
97 subroutine 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
106 end subroutine s15