1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wsign-conversion | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s -Wsign-conversion -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -Wsign-conversion -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
8 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
9 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
11 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wsign-conversion | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
12 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
13 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s -Wsign-conversion -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
17 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -Wsign-conversion -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
18 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
19 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
20 // expected-no-diagnostics
39 typename
T::type c
:12;
41 S7() : a(0), b(a
), c(0), d(a
.a
) {}
44 S7(typename
T::type v
) : a(v
), b(a
), c(v
), d(a
.a
) {
45 #pragma omp for private(a) private(this->a) private(T::a)
46 for (int k
= 0; k
< a
.a
; ++k
)
48 #pragma omp for lastprivate(a) lastprivate(this->a) lastprivate(T::a)
49 for (int k
= 0; k
< a
.a
; ++k
)
52 #pragma omp for linear(c: val)
54 #pragma omp for linear(val(c))
56 for (int k
= 0; k
< a
.a
; ++k
)
59 S7
&operator=(S7
&s
) {
60 #pragma omp for private(a) private(this->a)
61 for (int k
= 0; k
< s
.a
.a
; ++k
)
63 #pragma omp for lastprivate(a) lastprivate(this->a)
64 for (int k
= 0; k
< s
.a
.a
; ++k
)
67 #pragma omp for linear(this->b: uval)
69 #pragma omp for linear(uval(this->b))
71 for (int k
= 0; k
< s
.a
.a
; ++k
)
77 // CHECK: #pragma omp for private(this->a) private(this->a) private(T::a)
78 // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(T::a)
79 // CHECK: #pragma omp for linear(this->c: val)
80 // CHECK: #pragma omp for private(this->a) private(this->a)
81 // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a)
82 // CHECK: #pragma omp for linear(this->b: uval)
83 // CHECK: #pragma omp for private(this->a) private(this->a) private(this->S::a)
84 // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(this->S::a)
85 // CHECK: #pragma omp for linear(this->c: val)
87 class S8
: public S7
<S
> {
92 #pragma omp for private(a) private(this->a) private(S7<S>::a)
93 for (int k
= 0; k
< a
.a
; ++k
)
95 #pragma omp for lastprivate(a) lastprivate(this->a) lastprivate(S7<S>::a)
96 for (int k
= 0; k
< a
.a
; ++k
)
99 #pragma omp for linear(S7<S>::d: ref)
101 #pragma omp for linear(ref(S7<S>::d))
103 for (int k
= 0; k
< a
.a
; ++k
)
106 S8
&operator=(S8
&s
) {
107 #pragma omp for private(a) private(this->a)
108 for (int k
= 0; k
< s
.a
.a
; ++k
)
110 #pragma omp for lastprivate(a) lastprivate(this->a)
111 for (int k
= 0; k
< s
.a
.a
; ++k
)
113 #pragma omp for linear(this->c)
114 for (int k
= 0; k
< s
.a
.a
; ++k
)
120 // CHECK: #pragma omp for private(this->a) private(this->a) private(this->S7<S>::a)
121 // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(this->S7<S>::a)
122 // CHECK: #pragma omp for linear(this->S7<S>::d: ref)
123 // CHECK: #pragma omp for private(this->a) private(this->a)
124 // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a)
125 // CHECK: #pragma omp for linear(this->c)
127 template <class T
, int N
>
129 T b
= argc
, c
, d
, e
, f
, g
;
132 // CHECK: static T a;
133 #pragma omp for schedule(dynamic) linear(a) allocate(a)
134 // CHECK-NEXT: #pragma omp for schedule(dynamic) linear(a) allocate(a)
135 for (int i
= 0; i
< 2; ++i
)
137 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
138 // CHECK-NEXT: a = 2;
139 #pragma omp for schedule(nonmonotonic: dynamic)
140 // CHECK-NEXT: #pragma omp for schedule(nonmonotonic: dynamic)
141 for (int i
= 0; i
< 2; ++i
)
143 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
144 // CHECK-NEXT: a = 2;
145 #pragma omp for schedule(monotonic : dynamic)
146 // CHECK-NEXT: #pragma omp for schedule(monotonic: dynamic)
147 for (int i
= 0; i
< 2; ++i
)
149 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
150 // CHECK-NEXT: a = 2;
151 #pragma omp for schedule(nonmonotonic : guided)
152 // CHECK-NEXT: #pragma omp for schedule(nonmonotonic: guided)
153 for (int i
= 0; i
< 2; ++i
)
155 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
156 // CHECK-NEXT: a = 2;
157 #pragma omp for schedule(monotonic : guided)
158 // CHECK-NEXT: #pragma omp for schedule(monotonic: guided)
159 for (int i
= 0; i
< 2; ++i
)
161 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
162 // CHECK-NEXT: a = 2;
163 #pragma omp for schedule(nonmonotonic : static)
164 // CHECK-NEXT: #pragma omp for schedule(nonmonotonic: static)
165 for (int i
= 0; i
< 2; ++i
)
167 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
168 // CHECK-NEXT: a = 2;
169 #pragma omp for schedule(monotonic :static)
170 // CHECK-NEXT: #pragma omp for schedule(monotonic: static)
171 for (int i
= 0; i
< 2; ++i
)
173 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
174 // CHECK-NEXT: a = 2;
175 #pragma omp for schedule(nonmonotonic : auto)
176 // CHECK-NEXT: #pragma omp for schedule(nonmonotonic: auto)
177 for (int i
= 0; i
< 2; ++i
)
179 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
180 // CHECK-NEXT: a = 2;
181 #pragma omp for schedule(monotonic : auto)
182 // CHECK-NEXT: #pragma omp for schedule(monotonic: auto)
183 for (int i
= 0; i
< 2; ++i
)
185 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
186 // CHECK-NEXT: a = 2;
187 #pragma omp for schedule(nonmonotonic : runtime)
188 // CHECK-NEXT: #pragma omp for schedule(nonmonotonic: runtime)
189 for (int i
= 0; i
< 2; ++i
)
191 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
192 // CHECK-NEXT: a = 2;
193 #pragma omp for schedule(monotonic : runtime)
194 // CHECK-NEXT: #pragma omp for schedule(monotonic: runtime)
195 for (int i
= 0; i
< 2; ++i
)
197 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
198 // CHECK-NEXT: a = 2;
200 #pragma omp for allocate(argc) private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) nowait
201 for (auto &x
: arr
) {
203 for (int i
= 0; i
< 2; ++i
) {
205 for (int j
= 0; j
< 2; ++j
)
206 for (int j
= 0; j
< 2; ++j
)
207 for (int j
= 0; j
< 2; ++j
)
208 for (int j
= 0; j
< 2; ++j
)
209 for (int i
= 0; i
< 2; ++i
)
210 for (int j
= 0; j
< 2; ++j
)
211 for (int j
= 0; j
< 2; ++j
)
212 for (int j
= 0; j
< 2; ++j
)
213 for (int j
= 0; j
< 2; ++j
)
219 // CHECK-NEXT: #pragma omp parallel
220 // CHECK-NEXT: #pragma omp for allocate(argc) private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait
221 // CHECK-NEXT: for (auto &x : arr) {
222 // CHECK-NEXT: int j, hhh = 0;
223 // CHECK-NEXT: for (int i = 0; i < 2; ++i) {
224 // CHECK-NEXT: int j, hhh = 0;
225 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
226 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
227 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
228 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
229 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
230 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
231 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
232 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
233 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
234 // CHECK-NEXT: foo();
235 // CHECK-NEXT: ++hhh;
237 // CHECK-NEXT: ++hhh;
242 int main(int argc
, char **argv
) {
243 // CHECK: int main(int argc, char **argv) {
244 int b
= argc
, c
, d
, e
, f
, g
;
247 // CHECK: static int a;
249 #pragma omp for schedule(guided, argc) reduction(+:argv[0][:1]) order(unconstrained:concurrent)
251 #pragma omp for schedule(guided, argc) reduction(+:argv[0][:1]) order(unconstrained:concurrent)
253 #pragma omp for schedule(guided, argc) reduction(+:argv[0][:1]) order(concurrent)
255 // OMP50: #pragma omp for schedule(guided, argc) reduction(+: argv[0][:1]) order(concurrent)
256 // OMP51: #pragma omp for schedule(guided, argc) reduction(+: argv[0][:1]) order(unconstrained: concurrent)
257 // OMP52: #pragma omp for schedule(guided, argc) reduction(+: argv[0][:1]) order(unconstrained: concurrent)
258 for (int i
= argc
; i
< c
; ++i
)
260 // CHECK-NEXT: for (int i = argc; i < c; ++i)
261 // CHECK-NEXT: a = 2;
264 #pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(3) schedule(auto) ordered nowait linear(g: step(-1)) reduction(task, +:e)
266 #pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(3) schedule(auto) ordered nowait linear(g:-1) reduction(task, +:e)
268 for (int i
= 0; i
< 10; ++i
)
269 for (int j
= 0; j
< 10; ++j
)
272 // CHECK-NEXT: #pragma omp parallel
273 // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(3) schedule(auto) ordered nowait linear(g: step(-1)) reduction(task, +: e)
274 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
275 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
276 // CHECK-NEXT: for (auto x : arr)
277 // CHECK-NEXT: foo() , (void)x;
278 char buf
[9] = "01234567";
282 for (p
= buf
; p
< &buf
[8]; p
++)
283 for (q
= &buf
[0]; q
<= buf
+ 7; q
++)
285 // CHECK: #pragma omp parallel
286 // CHECK-NEXT: #pragma omp for{{$}}
287 // CHECK-NEXT: for (p = buf; p < &buf[8]; p++)
288 // CHECK-NEXT: for (q = &buf[0]; q <= buf + 7; q++)
289 // CHECK-NEXT: foo();
290 return (tmain
<int, 5>(argc
) + tmain
<char, 1>(argv
[0][0]));