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
) {
14 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
15 #pragma omp parallel for 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 2 {{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 4 {{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
) {
79 #pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
80 for (int k
= 0; k
< argc
; ++k
)
82 #pragma omp parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (int k
= 0; k
< argc
; ++k
)
85 #pragma omp parallel for firstprivate() // expected-error {{expected expression}}
86 for (int k
= 0; k
< argc
; ++k
)
88 #pragma omp parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
89 for (int k
= 0; k
< argc
; ++k
)
91 #pragma omp parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (int k
= 0; k
< argc
; ++k
)
94 #pragma omp parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
95 for (int k
= 0; k
< argc
; ++k
)
97 #pragma omp parallel 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 '('}}
98 for (int k
= 0; k
< argc
; ++k
)
100 #pragma omp parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
101 for (int k
= 0; k
< argc
; ++k
)
103 #pragma omp parallel for firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
104 for (int k
= 0; k
< argc
; ++k
)
106 #pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
107 for (int k
= 0; k
< argc
; ++k
)
109 #pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
110 for (int k
= 0; k
< argc
; ++k
)
112 #pragma omp parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
113 for (int k
= 0; k
< argc
; ++k
)
119 #pragma omp parallel for firstprivate(i)
120 for (int k
= 0; k
< argc
; ++k
) {
125 #pragma omp parallel shared(i)
126 #pragma omp parallel private(i)
127 #pragma omp parallel for firstprivate(j)
128 for (int k
= 0; k
< argc
; ++k
)
130 #pragma omp parallel for firstprivate(i)
131 for (int k
= 0; k
< argc
; ++k
)
133 #pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
134 for (i
= 0; i
< argc
; ++i
)
136 #pragma omp parallel private(i)
137 #pragma omp parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
138 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
140 #pragma omp parallel reduction(+ : i)
141 #pragma omp parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
142 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
149 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
155 int main(int argc
, char **argv
) {
157 const int da
[5] = {0};
164 #pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
165 for (i
= 0; i
< argc
; ++i
)
167 #pragma omp parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
168 for (i
= 0; i
< argc
; ++i
)
170 #pragma omp parallel for firstprivate() // expected-error {{expected expression}}
171 for (i
= 0; i
< argc
; ++i
)
173 #pragma omp parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
174 for (i
= 0; i
< argc
; ++i
)
176 #pragma omp parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
177 for (i
= 0; i
< argc
; ++i
)
179 #pragma omp parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
180 for (i
= 0; i
< argc
; ++i
)
182 #pragma omp parallel for firstprivate(argc)
183 for (i
= 0; i
< argc
; ++i
)
185 #pragma omp parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
186 for (i
= 0; i
< argc
; ++i
)
188 #pragma omp parallel for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
189 for (i
= 0; i
< argc
; ++i
)
191 #pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
192 for (i
= 0; i
< argc
; ++i
)
194 #pragma omp parallel for firstprivate(2 * 2) // expected-error {{expected variable name}}
195 for (i
= 0; i
< argc
; ++i
)
197 #pragma omp parallel for firstprivate(ba) // OK
198 for (i
= 0; i
< argc
; ++i
)
200 #pragma omp parallel for firstprivate(ca) // OK
201 for (i
= 0; i
< argc
; ++i
)
203 #pragma omp parallel for firstprivate(da) // OK
204 for (i
= 0; i
< argc
; ++i
)
207 #pragma omp parallel for firstprivate(xa) // OK
208 for (i
= 0; i
< argc
; ++i
)
210 #pragma omp parallel for firstprivate(S2::S2s) // OK
211 for (i
= 0; i
< argc
; ++i
)
213 #pragma omp parallel for firstprivate(S2::S2sc) // OK
214 for (i
= 0; i
< argc
; ++i
)
216 #pragma omp parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel for'}}
217 for (i
= 0; i
< argc
; ++i
)
219 #pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
220 for (i
= 0; i
< argc
; ++i
)
222 #pragma omp parallel for firstprivate(m) // OK
223 for (i
= 0; i
< argc
; ++i
)
225 #pragma omp parallel for firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
226 for (i
= 0; i
< argc
; ++i
)
228 #pragma omp parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
229 for (i
= 0; i
< argc
; ++i
)
231 #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
232 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
234 #pragma omp parallel shared(xa)
235 #pragma omp parallel for firstprivate(xa) // OK: may be firstprivate
236 for (i
= 0; i
< argc
; ++i
)
238 #pragma omp parallel for firstprivate(j)
239 for (i
= 0; i
< argc
; ++i
)
241 #pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
242 for (i
= 0; i
< argc
; ++i
)
244 #pragma omp parallel for lastprivate(n) firstprivate(n) // OK
245 for (i
= 0; i
< argc
; ++i
)
251 #pragma omp parallel for firstprivate(i)
252 for (int k
= 0; k
< argc
; ++k
) {
257 #pragma omp parallel private(i)
258 #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
259 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
261 #pragma omp parallel reduction(+ : i)
262 #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
263 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
266 #pragma omp parallel for firstprivate(si) // OK
267 for (i
= 0; i
< argc
; ++i
)
270 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}