Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / OpenMP / loop-association.f90
blob8a28fd8878f496505eff464e9096cb0b2a586d3e
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! Check the association between OpenMPLoopConstruct and DoConstruct
5 integer :: b = 128
6 integer :: c = 32
7 integer, parameter :: num = 16
8 N = 1024
10 ! Different DO loops
12 !$omp parallel
13 !$omp do
14 do 10 i=1, N
15 a = 3.14
16 10 print *, a
17 !$omp end parallel
19 !$omp parallel do
20 DO CONCURRENT (i = 1:N)
21 a = 3.14
22 END DO
24 !$omp parallel do simd
25 outer: DO WHILE (c > 1)
26 inner: do while (b > 100)
27 a = 3.14
28 b = b - 1
29 enddo inner
30 c = c - 1
31 END DO outer
33 c = 16
34 !ERROR: DO loop after the PARALLEL DO directive must have loop control
35 !$omp parallel do
37 a = 3.14
38 c = c - 1
39 if (c < 1) exit
40 enddo
42 ! Loop association check
44 ! If an end do directive follows a do-construct in which several DO
45 ! statements share a DO termination statement, then a do directive
46 ! can only be specified for the outermost of these DO statements.
47 do 100 i=1, N
48 !$omp do
49 do 100 j=1, N
50 a = 3.14
51 100 continue
52 !ERROR: The ENDDO directive must follow the DO loop associated with the loop construct
53 !$omp enddo
55 !$omp parallel do copyin(a)
56 do i = 1, N
57 !$omp parallel do
58 do j = 1, i
59 enddo
60 !$omp end parallel do
61 a = 3.
62 enddo
63 !$omp end parallel do
65 !$omp parallel do
66 do i = 1, N
67 enddo
68 !$omp end parallel do
69 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
70 !$omp end parallel do
72 !$omp parallel
73 a = 3.0
74 !$omp do simd
75 do i = 1, N
76 enddo
77 !$omp end do simd
79 !$omp parallel do copyin(a)
80 do i = 1, N
81 enddo
82 !$omp end parallel
84 a = 0.0
85 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
86 !$omp end parallel do
87 !$omp parallel do private(c)
88 do i = 1, N
89 do j = 1, N
90 !ERROR: A DO loop must follow the PARALLEL DO directive
91 !$omp parallel do shared(b)
92 a = 3.14
93 enddo
94 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
95 !$omp end parallel do
96 enddo
97 a = 1.414
98 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
99 !$omp end parallel do
101 do i = 1, N
102 !$omp parallel do
103 do j = 2*i*N, (2*i+1)*N
104 a = 3.14
105 enddo
106 enddo
107 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
108 !$omp end parallel do
110 !ERROR: A DO loop must follow the PARALLEL DO directive
111 !$omp parallel do private(c)
112 5 FORMAT (1PE12.4, I10)
113 do i=1, N
114 a = 3.14
115 enddo
116 !ERROR: The END PARALLEL DO directive must follow the DO loop associated with the loop construct
117 !$omp end parallel do
119 !$omp parallel do simd
120 do i = 1, N
121 a = 3.14
122 enddo
123 !$omp end parallel do simd
124 !ERROR: The END PARALLEL DO SIMD directive must follow the DO loop associated with the loop construct
125 !$omp end parallel do simd