[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / omp-nested-barrier.f90
blob14bc36d5e91afb311eee30849788b66d8a7d2e15
1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenmp
2 ! OpenMP Version 4.5
3 ! Various checks with the nesting of BARRIER construct
5 program omp_nest_barrier
6 integer i, k, j
7 k = 0;
9 !$omp do
10 do i = 1, 10
11 k = k + 1
12 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
13 !$omp barrier
14 j = j -1
15 end do
17 !$omp do simd
18 do i = 1, 10
19 k = k + 1
20 !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
21 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
22 !$omp barrier
23 j = j -1
24 end do
26 !$omp parallel do
27 do i = 1, 10
28 k = k + 1
29 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
30 !$omp barrier
31 j = j -1
32 end do
34 !$omp parallel do simd
35 do i = 1, 10
36 k = k + 1
37 !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
38 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
39 !$omp barrier
40 j = j -1
41 end do
43 !$omp parallel
44 do i = 1, 10
45 k = k + 1
46 !$omp barrier
47 j = j -1
48 end do
49 !$omp end parallel
51 !$omp task
52 do i = 1, 10
53 k = k + 1
54 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
55 !$omp barrier
56 j = j -1
57 end do
58 !$omp end task
60 !$omp taskloop
61 do i = 1, 10
62 k = k + 1
63 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
64 !$omp barrier
65 j = j -1
66 end do
67 !$omp end taskloop
69 !$omp critical
70 do i = 1, 10
71 k = k + 1
72 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
73 !$omp barrier
74 j = j -1
75 end do
76 !$omp end critical
78 !$omp master
79 do i = 1, 10
80 k = k + 1
81 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
82 !$omp barrier
83 j = j -1
84 end do
85 !$omp end master
87 !$omp ordered
88 do i = 1, 10
89 k = k + 1
90 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
91 !$omp barrier
92 j = j -1
93 end do
94 !$omp end ordered
96 !$omp ordered
97 do i = 1, 10
98 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
99 !$omp distribute
100 do k =1, 10
101 print *, "hello"
102 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
103 !$omp barrier
104 j = j -1
105 end do
106 !$omp end distribute
107 end do
108 !$omp end ordered
110 !$omp master
111 do i = 1, 10
112 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
113 !$omp distribute
114 do k =1, 10
115 print *, "hello"
116 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
117 !$omp barrier
118 j = j -1
119 end do
120 !$omp end distribute
121 end do
122 !$omp end master
124 !$omp critical
125 do i = 1, 10
126 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
127 !$omp distribute
128 do k =1, 10
129 print *, "hello"
130 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
131 !$omp barrier
132 j = j -1
133 end do
134 !$omp end distribute
135 end do
136 !$omp end critical
138 !$omp taskloop
139 do i = 1, 10
140 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
141 !$omp distribute
142 do k =1, 10
143 print *, "hello"
144 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
145 !$omp barrier
146 j = j -1
147 end do
148 !$omp end distribute
149 end do
150 !$omp end taskloop
152 !$omp task
153 do i = 1, 10
154 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
155 !$omp distribute
156 do k =1, 10
157 print *, "hello"
158 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
159 !$omp barrier
160 j = j -1
161 end do
162 !$omp end distribute
163 end do
164 !$omp end task
166 end program omp_nest_barrier