[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / dosemantics09.f90
blob4f2c5bf180400742981de7cc66bc821df77e5856
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.
9 subroutine s1()
11 !ERROR: 'i' is already declared in this scoping unit
12 do concurrent (i=1:10) local(i)
13 end do
14 end subroutine s1
16 subroutine s2()
17 !ERROR: 'i' is already declared in this scoping unit
18 do concurrent (i=1:10) local_init(i)
19 end do
20 end subroutine s2
22 subroutine s4()
23 !ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
24 do concurrent (j=i:10) local(i)
25 end do
26 end subroutine s4
28 subroutine s5()
29 !OK because the locality-spec is local_init
30 do concurrent (j=i:10) local_init(i)
31 end do
32 end subroutine s5
34 subroutine s6()
35 !OK because the locality-spec is shared
36 do concurrent (j=i:10) shared(i)
37 end do
38 end subroutine s6
40 subroutine s7()
41 !ERROR: DO CONCURRENT expression references variable 'i' in LOCAL locality-spec
42 do concurrent (j=1:i) local(i)
43 end do
44 end subroutine s7
46 subroutine s8()
47 !OK because the locality-spec is local_init
48 do concurrent (j=1:i) local_init(i)
49 end do
50 end subroutine s8
52 subroutine s9()
53 !OK because the locality-spec is shared
54 do concurrent (j=1:i) shared(i)
55 end do
56 end subroutine s9
58 subroutine 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
62 end subroutine s10
64 subroutine s11()
65 !OK because the locality-spec is local_init
66 do concurrent (j=1:10:i) local_init(i)
67 end do
68 end subroutine s11
70 subroutine s12()
71 !OK because the locality-spec is shared
72 do concurrent (j=1:10:i) shared(i)
73 end do
74 end subroutine s12
76 subroutine 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
84 end subroutine s13
86 module m1
87 integer :: mvar
88 end module m1
89 subroutine s14()
90 ! Test use-association, in this case, established by the "shared"
91 use m1
93 !ERROR: DO CONCURRENT expression references variable 'mvar' in LOCAL locality-spec
94 do concurrent (k=mvar:10) local(mvar)
95 end do
96 end subroutine s14
98 subroutine 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
107 end subroutine s15