[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-loop-association.f90
blob5e7dce62413591d00f21e64fc4b05dd9054eea4f
1 ! RUN: %S/test_errors.sh %s %t %flang -fopenmp
2 ! REQUIRES: shell
4 ! Check the association between OpenMPLoopConstruct and DoConstruct
6 integer :: b = 128
7 integer :: c = 32
8 integer, parameter :: num = 16
9 N = 1024
11 ! Different DO loops
13 !$omp parallel
14 !$omp do
15 do 10 i=1, N
16 a = 3.14
17 10 print *, a
18 !$omp end parallel
20 !$omp parallel do
21 DO CONCURRENT (i = 1:N)
22 a = 3.14
23 END DO
25 !$omp parallel do simd
26 outer: DO WHILE (c > 1)
27 inner: do while (b > 100)
28 a = 3.14
29 b = b - 1
30 enddo inner
31 c = c - 1
32 END DO outer
34 c = 16
35 !ERROR: DO loop after the PARALLEL DO directive must have loop control
36 !$omp parallel do
38 a = 3.14
39 c = c - 1
40 if (c < 1) exit
41 enddo
43 ! Loop association check
45 ! If an end do directive follows a do-construct in which several DO
46 ! statements share a DO termination statement, then a do directive
47 ! can only be specified for the outermost of these DO statements.
48 do 100 i=1, N
49 !$omp do
50 do 100 j=1, N
51 a = 3.14
52 100 continue
53 !ERROR: The ENDDO directive must follow the DO loop associated with the loop construct
54 !$omp enddo
56 !$omp parallel do copyin(a)
57 do i = 1, N
58 !$omp parallel do
59 do j = 1, i
60 enddo
61 !$omp end parallel do
62 a = 3.
63 enddo
64 !$omp end parallel do
66 !$omp parallel do
67 do i = 1, N
68 enddo
69 !$omp end parallel do
70 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
71 !$omp end parallel do
73 !$omp parallel
74 a = 3.0
75 !$omp do simd
76 do i = 1, N
77 enddo
78 !$omp end do simd
80 !$omp parallel do copyin(a)
81 do i = 1, N
82 enddo
83 !$omp end parallel
85 a = 0.0
86 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
87 !$omp end parallel do
88 !$omp parallel do private(c)
89 do i = 1, N
90 do j = 1, N
91 !ERROR: A DO loop must follow the PARALLEL DO directive
92 !$omp parallel do shared(b)
93 a = 3.14
94 enddo
95 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
96 !$omp end parallel do
97 enddo
98 a = 1.414
99 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
100 !$omp end parallel do
102 do i = 1, N
103 !$omp parallel do
104 do j = 2*i*N, (2*i+1)*N
105 a = 3.14
106 enddo
107 enddo
108 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
109 !$omp end parallel do
111 !ERROR: A DO loop must follow the PARALLEL DO directive
112 !$omp parallel do private(c)
113 5 FORMAT (1PE12.4, I10)
114 do i=1, N
115 a = 3.14
116 enddo
117 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
118 !$omp end parallel do
120 !$omp parallel do simd
121 do i = 1, N
122 a = 3.14
123 enddo
124 !$omp end parallel do simd
125 !ERROR: The END PARALLEL DO SIMD directive must follow the DO loop associated with the loop construct
126 !$omp end parallel do simd