1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 extern int omp_default_mem_alloc
;
9 bool foobool(int argc
) {
13 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
20 S2(const S2
&s2
) : a(s2
.a
) {}
22 static const float S2sc
;
24 const float S2::S2sc
= 0;
29 S3
&operator=(const S3
&s3
);
33 S3(const S3
&s3
) : a(s3
.a
) {}
41 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
48 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 2 {{implicitly declared private here}}
56 S6() : a(0) {} // expected-note {{implicitly declared private here}}
59 S6(const S6
&s6
) : a(s6
.a
) {}
64 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
66 template <class I
, class C
>
67 int foomain(int argc
, char **argv
) {
74 #pragma omp distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
75 for (int k
= 0; k
< argc
; ++k
)
79 #pragma omp distribute simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80 for (int k
= 0; k
< argc
; ++k
)
84 #pragma omp distribute simd firstprivate() // expected-error {{expected expression}}
85 for (int k
= 0; k
< argc
; ++k
)
89 #pragma omp distribute simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
90 for (int k
= 0; k
< argc
; ++k
)
94 #pragma omp distribute simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int k
= 0; k
< argc
; ++k
)
99 #pragma omp distribute simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
100 for (int k
= 0; k
< argc
; ++k
)
104 #pragma omp distribute 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 '('}}
105 for (int k
= 0; k
< argc
; ++k
)
109 #pragma omp distribute simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
110 for (int k
= 0; k
< argc
; ++k
)
114 #pragma omp distribute simd firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}}
115 for (int k
= 0; k
< argc
; ++k
)
119 #pragma omp distribute simd firstprivate(argv[1]) // expected-error {{expected variable name}}
120 for (int k
= 0; k
< argc
; ++k
)
124 #pragma omp distribute simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
125 for (int k
= 0; k
< argc
; ++k
)
129 #pragma omp distribute simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
130 for (int k
= 0; k
< argc
; ++k
)
138 #pragma omp distribute simd firstprivate(i)
139 for (int k
= 0; k
< argc
; ++k
) {
144 #pragma omp parallel shared(i)
145 #pragma omp parallel private(i)
148 #pragma omp distribute simd firstprivate(j)
149 for (int k
= 0; k
< argc
; ++k
)
153 #pragma omp distribute simd firstprivate(i)
154 for (int k
= 0; k
< argc
; ++k
)
156 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
159 #pragma omp distribute simd lastprivate(g) firstprivate(g)
160 for (i
= 0; i
< argc
; ++i
)
162 #pragma omp parallel private(i)
165 #pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
166 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
168 #pragma omp parallel reduction(+ : i)
171 #pragma omp distribute simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
172 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
179 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
185 int main(int argc
, char **argv
) {
187 const int da
[5] = {0};
196 #pragma omp distribute simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
197 for (i
= 0; i
< argc
; ++i
)
201 #pragma omp distribute simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
202 for (i
= 0; i
< argc
; ++i
)
206 #pragma omp distribute simd firstprivate() // expected-error {{expected expression}}
207 for (i
= 0; i
< argc
; ++i
)
211 #pragma omp distribute simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
212 for (i
= 0; i
< argc
; ++i
)
216 #pragma omp distribute simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
217 for (i
= 0; i
< argc
; ++i
)
221 #pragma omp distribute simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
222 for (i
= 0; i
< argc
; ++i
)
226 #pragma omp distribute simd firstprivate(argc, z)
227 for (i
= 0; i
< argc
; ++i
)
231 #pragma omp distribute simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
232 for (i
= 0; i
< argc
; ++i
)
236 #pragma omp distribute 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}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}}
237 for (i
= 0; i
< argc
; ++i
)
241 #pragma omp distribute simd firstprivate(argv[1]) // expected-error {{expected variable name}}
242 for (i
= 0; i
< argc
; ++i
)
246 #pragma omp distribute simd firstprivate(2 * 2) // expected-error {{expected variable name}}
247 for (i
= 0; i
< argc
; ++i
)
251 #pragma omp distribute simd firstprivate(ba) // expected-warning {{type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
252 for (i
= 0; i
< argc
; ++i
)
256 #pragma omp distribute simd firstprivate(ca) // expected-warning {{type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
257 for (i
= 0; i
< argc
; ++i
)
261 #pragma omp distribute simd firstprivate(da) // OK
262 for (i
= 0; i
< argc
; ++i
)
267 #pragma omp distribute simd firstprivate(xa) // OK
268 for (i
= 0; i
< argc
; ++i
)
272 #pragma omp distribute simd firstprivate(S2::S2s) // OK
273 for (i
= 0; i
< argc
; ++i
)
277 #pragma omp distribute simd firstprivate(S2::S2sc) // OK
278 for (i
= 0; i
< argc
; ++i
)
282 #pragma omp distribute simd safelen(5) // OK
283 for (i
= 0; i
< argc
; ++i
)
287 #pragma omp distribute simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
288 for (i
= 0; i
< argc
; ++i
)
292 #pragma omp distribute simd firstprivate(m) // expected-warning {{type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}
293 for (i
= 0; i
< argc
; ++i
)
297 #pragma omp distribute simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
298 for (i
= 0; i
< argc
; ++i
)
302 #pragma omp distribute simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
303 for (i
= 0; i
< argc
; ++i
)
307 #pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
308 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
310 #pragma omp parallel shared(xa)
313 #pragma omp distribute simd firstprivate(xa) // OK: may be firstprivate
314 for (i
= 0; i
< argc
; ++i
)
318 #pragma omp distribute simd firstprivate(j)
319 for (i
= 0; i
< argc
; ++i
)
321 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
324 #pragma omp distribute simd lastprivate(g) firstprivate(g) //expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
325 for (i
= 0; i
< argc
; ++i
)
327 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
330 #pragma omp distribute simd lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}} expected-warning {{type 'S6' is not trivially copyable and not guaranteed to be mapped correctly}}
331 for (i
= 0; i
< argc
; ++i
)
339 #pragma omp distribute simd firstprivate(i)
340 for (int k
= 0; k
< argc
; ++k
) {
345 #pragma omp parallel private(i)
348 #pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
349 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
351 #pragma omp parallel reduction(+ : i)
354 #pragma omp distribute simd firstprivate(i) // expected-note {{defined as firstprivate}}
355 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be firstprivate, predetermined as linear}}
360 #pragma omp distribute simd firstprivate(si) // OK
361 for (i
= 0; i
< argc
; ++i
)
364 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}