1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
4 extern int omp_default_mem_alloc
;
8 bool foobool(int argc
) {
12 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
19 S2(const S2
&s2
) : a(s2
.a
) {}
21 static const float S2sc
;
23 const float S2::S2sc
= 0;
28 S3
&operator=(const S3
&s3
);
31 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
32 S3(S3
&s3
) : a(s3
.a
) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
40 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
47 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
58 S6(const S6
&s6
) : a(s6
.a
) {}
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
65 template <class I
, class C
>
66 int foomain(int argc
, char **argv
) {
72 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
73 for (int k
= 0; k
< argc
; ++k
)
76 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 for (int k
= 0; k
< argc
; ++k
)
80 #pragma omp for firstprivate() // expected-error {{expected expression}}
81 for (int k
= 0; k
< argc
; ++k
)
84 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
85 for (int k
= 0; k
< argc
; ++k
)
88 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
89 for (int k
= 0; k
< argc
; ++k
)
92 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
93 for (int k
= 0; k
< argc
; ++k
)
96 #pragma omp for 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 '('}}
97 for (int k
= 0; k
< argc
; ++k
)
100 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
101 for (int k
= 0; k
< argc
; ++k
)
104 #pragma omp for firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
105 for (int k
= 0; k
< argc
; ++k
)
108 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
109 for (int k
= 0; k
< argc
; ++k
)
112 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
113 for (int k
= 0; k
< argc
; ++k
)
116 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
117 for (int k
= 0; k
< argc
; ++k
)
122 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
123 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
124 for (int k
= 0; k
< argc
; ++k
) {
129 #pragma omp parallel shared(i)
130 #pragma omp parallel private(i)
131 #pragma omp for firstprivate(j)
132 for (int k
= 0; k
< argc
; ++k
)
135 #pragma omp for firstprivate(i)
136 for (int k
= 0; k
< argc
; ++k
)
139 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
140 for (i
= 0; i
< argc
; ++i
)
142 #pragma omp parallel private(i) // expected-note {{defined as private}}
143 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
144 for (i
= 0; i
< argc
; ++i
)
146 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
147 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
148 for (int k
= 0; k
< argc
; ++k
)
155 #pragma omp for firstprivate(a)
156 for (int i
= 0; i
< 2; ++i
)
162 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
168 int main(int argc
, char **argv
) {
170 const int da
[5] = {0};
178 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
179 for (i
= 0; i
< argc
; ++i
)
182 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
183 for (i
= 0; i
< argc
; ++i
)
186 #pragma omp for firstprivate() // expected-error {{expected expression}}
187 for (i
= 0; i
< argc
; ++i
)
190 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
191 for (i
= 0; i
< argc
; ++i
)
194 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
195 for (i
= 0; i
< argc
; ++i
)
198 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
199 for (i
= 0; i
< argc
; ++i
)
202 #pragma omp for firstprivate(argc)
203 for (i
= 0; i
< argc
; ++i
)
206 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
207 for (i
= 0; i
< argc
; ++i
)
210 #pragma omp for firstprivate(a, b, c, d, f, k) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
211 for (i
= 0; i
< argc
; ++i
)
214 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
215 for (i
= 0; i
< argc
; ++i
)
218 #pragma omp for firstprivate(2 * 2) // expected-error {{expected variable name}}
219 for (i
= 0; i
< argc
; ++i
)
222 #pragma omp for firstprivate(ba) // OK
223 for (i
= 0; i
< argc
; ++i
)
226 #pragma omp for firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
227 for (i
= 0; i
< argc
; ++i
)
230 #pragma omp for firstprivate(da) // OK
231 for (i
= 0; i
< argc
; ++i
)
235 #pragma omp for firstprivate(xa) // OK
236 for (i
= 0; i
< argc
; ++i
)
239 #pragma omp for firstprivate(S2::S2s) // OK
240 for (i
= 0; i
< argc
; ++i
)
243 #pragma omp for firstprivate(S2::S2sc) // OK
244 for (i
= 0; i
< argc
; ++i
)
247 #pragma omp for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp for'}}
248 for (i
= 0; i
< argc
; ++i
)
251 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
252 for (i
= 0; i
< argc
; ++i
)
255 #pragma omp for firstprivate(m) // OK
256 for (i
= 0; i
< argc
; ++i
)
259 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
260 for (i
= 0; i
< argc
; ++i
)
263 #pragma omp for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
264 for (i
= 0; i
< argc
; ++i
)
267 #pragma omp for firstprivate(i) // expected-note {{defined as firstprivate}}
268 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp for' directive may not be firstprivate, predetermined as private}}
270 #pragma omp parallel shared(xa)
271 #pragma omp for firstprivate(xa) // OK: may be firstprivate
272 for (i
= 0; i
< argc
; ++i
)
275 #pragma omp for firstprivate(j)
276 for (i
= 0; i
< argc
; ++i
)
279 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
280 for (i
= 0; i
< argc
; ++i
)
283 #pragma omp for lastprivate(n) firstprivate(n) // OK
284 for (i
= 0; i
< argc
; ++i
)
289 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
290 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
291 for (int k
= 0; k
< argc
; ++k
) {
296 #pragma omp parallel private(i) // expected-note {{defined as private}}
297 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
298 for (i
= 0; i
< argc
; ++i
)
300 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
301 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
302 for (i
= 0; i
< argc
; ++i
)
305 #pragma omp for firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
306 for (i
= 0; i
< argc
; ++i
)
309 #pragma omp for firstprivate(si) // OK
310 for (i
= 0; i
< argc
; ++i
)
313 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}