1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized
5 extern int omp_default_mem_alloc
;
9 bool foobool(int argc
) {
14 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
15 #pragma omp distribute parallel for simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
16 for (int i
= 0; i
< 10; ++i
)
20 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
27 S2(const S2
&s2
) : a(s2
.a
) {}
29 static const float S2sc
;
31 const float S2::S2sc
= 0;
36 S3
&operator=(const S3
&s3
);
40 S3(const S3
&s3
) : a(s3
.a
) {}
48 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
55 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 2 {{implicitly declared private here}}
63 S6() : a(0) {} // expected-note {{implicitly declared private here}}
66 S6(const S6
&s6
) : a(s6
.a
) {}
71 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
73 template <class I
, class C
>
74 int foomain(int argc
, char **argv
) {
81 #pragma omp distribute parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
82 for (int k
= 0; k
< argc
; ++k
)
86 #pragma omp distribute parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87 for (int k
= 0; k
< argc
; ++k
)
91 #pragma omp distribute parallel for simd firstprivate() // expected-error {{expected expression}}
92 for (int k
= 0; k
< argc
; ++k
)
96 #pragma omp distribute parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (int k
= 0; k
< argc
; ++k
)
101 #pragma omp distribute parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
102 for (int k
= 0; k
< argc
; ++k
)
106 #pragma omp distribute parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
107 for (int k
= 0; k
< argc
; ++k
)
111 #pragma omp distribute parallel for simd firstprivate(argc, z)
112 for (int k
= 0; k
< argc
; ++k
)
116 #pragma omp distribute parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
117 for (int k
= 0; k
< argc
; ++k
)
121 #pragma omp distribute parallel for simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
122 for (int k
= 0; k
< argc
; ++k
)
126 #pragma omp distribute parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
127 for (int k
= 0; k
< argc
; ++k
)
131 #pragma omp distribute parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
132 for (int k
= 0; k
< argc
; ++k
)
136 #pragma omp distribute parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
137 for (int k
= 0; k
< argc
; ++k
)
145 #pragma omp distribute parallel for simd firstprivate(i)
146 for (int k
= 0; k
< argc
; ++k
) {
151 #pragma omp parallel shared(i)
152 #pragma omp parallel private(i)
155 #pragma omp distribute parallel for simd firstprivate(j)
156 for (int k
= 0; k
< argc
; ++k
)
160 #pragma omp distribute parallel for simd firstprivate(i)
161 for (int k
= 0; k
< argc
; ++k
)
163 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
166 #pragma omp distribute parallel for simd lastprivate(g) firstprivate(g)
167 for (i
= 0; i
< argc
; ++i
)
169 #pragma omp parallel private(i)
172 #pragma omp distribute parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
173 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
175 #pragma omp parallel reduction(+ : i)
178 #pragma omp distribute parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
179 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
186 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
192 int main(int argc
, char **argv
) {
194 const int da
[5] = {0};
203 #pragma omp distribute parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
204 for (i
= 0; i
< argc
; ++i
)
208 #pragma omp distribute parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
209 for (i
= 0; i
< argc
; ++i
)
213 #pragma omp distribute parallel for simd firstprivate() // expected-error {{expected expression}}
214 for (i
= 0; i
< argc
; ++i
)
218 #pragma omp distribute parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
219 for (i
= 0; i
< argc
; ++i
)
223 #pragma omp distribute parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
224 for (i
= 0; i
< argc
; ++i
)
228 #pragma omp distribute parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
229 for (i
= 0; i
< argc
; ++i
)
233 #pragma omp distribute parallel for simd firstprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
234 for (i
= 0; i
< argc
; ++i
)
238 #pragma omp distribute parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
239 for (i
= 0; i
< argc
; ++i
)
243 #pragma omp distribute parallel for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}}
244 for (i
= 0; i
< argc
; ++i
)
248 #pragma omp distribute parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
249 for (i
= 0; i
< argc
; ++i
)
253 #pragma omp distribute parallel for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
254 for (i
= 0; i
< argc
; ++i
)
258 #pragma omp distribute parallel for simd firstprivate(ba, z) // OK
259 for (i
= 0; i
< argc
; ++i
)
263 #pragma omp distribute parallel for simd firstprivate(ca) // OK
264 for (i
= 0; i
< argc
; ++i
)
268 #pragma omp distribute parallel for simd firstprivate(da) // OK
269 for (i
= 0; i
< argc
; ++i
)
274 #pragma omp distribute parallel for simd firstprivate(xa) // OK
275 for (i
= 0; i
< argc
; ++i
)
279 #pragma omp distribute parallel for simd firstprivate(S2::S2s) // OK
280 for (i
= 0; i
< argc
; ++i
)
284 #pragma omp distribute parallel for simd firstprivate(S2::S2sc) // OK
285 for (i
= 0; i
< argc
; ++i
)
289 #pragma omp distribute parallel for simd safelen(5) // OK
290 for (i
= 0; i
< argc
; ++i
)
294 #pragma omp distribute parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
295 for (i
= 0; i
< argc
; ++i
)
299 #pragma omp distribute parallel for simd firstprivate(m) // OK
300 for (i
= 0; i
< argc
; ++i
)
304 #pragma omp distribute parallel for simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
305 for (i
= 0; i
< argc
; ++i
)
309 #pragma omp distribute parallel for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
310 for (i
= 0; i
< argc
; ++i
)
314 #pragma omp distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
315 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
317 #pragma omp parallel shared(xa)
320 #pragma omp distribute parallel for simd firstprivate(xa) // OK: may be firstprivate
321 for (i
= 0; i
< argc
; ++i
)
325 #pragma omp distribute parallel for simd firstprivate(j)
326 for (i
= 0; i
< argc
; ++i
)
328 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
331 #pragma omp distribute parallel for simd lastprivate(g) firstprivate(g)
332 for (i
= 0; i
< argc
; ++i
)
334 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
337 #pragma omp distribute parallel for simd lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}}
338 for (i
= 0; i
< argc
; ++i
)
346 #pragma omp distribute parallel for simd firstprivate(i)
347 for (int k
= 0; k
< argc
; ++k
) {
352 #pragma omp parallel private(i)
355 #pragma omp distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
356 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
358 #pragma omp parallel reduction(+ : i)
361 #pragma omp distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
362 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
367 #pragma omp distribute parallel for simd firstprivate(si) // OK
368 for (i
= 0; i
< argc
; ++i
)
371 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}