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 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 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 simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
80 for (int k
= 0; k
< argc
; ++k
)
82 #pragma omp parallel for simd 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 simd firstprivate() // expected-error {{expected expression}}
86 for (int k
= 0; k
< argc
; ++k
)
88 #pragma omp parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
89 for (int k
= 0; k
< argc
; ++k
)
91 #pragma omp parallel for simd 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 simd 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 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 '('}}
98 for (int k
= 0; k
< argc
; ++k
)
100 #pragma omp parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
101 for (int k
= 0; k
< argc
; ++k
)
103 #pragma omp parallel for simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
104 for (int k
= 0; k
< argc
; ++k
)
106 #pragma omp parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
107 for (int k
= 0; k
< argc
; ++k
)
109 #pragma omp parallel for simd 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 simd firstprivate(h, z) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
113 for (int k
= 0; k
< argc
; ++k
)
115 #pragma omp parallel for simd linear(i)
116 for (int k
= 0; k
< argc
; ++k
)
121 #pragma omp parallel for simd firstprivate(i)
122 for (int k
= 0; k
< argc
; ++k
) {
127 #pragma omp parallel shared(i)
128 #pragma omp parallel private(i)
129 #pragma omp parallel for simd firstprivate(j)
130 for (int k
= 0; k
< argc
; ++k
)
132 #pragma omp parallel for simd firstprivate(i)
133 for (int k
= 0; k
< argc
; ++k
)
135 #pragma omp parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
136 for (i
= 0; i
< argc
; ++i
)
138 #pragma omp parallel private(i)
139 #pragma omp parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
140 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
142 #pragma omp parallel reduction(+ : i)
143 #pragma omp parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
144 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
151 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
157 int main(int argc
, char **argv
) {
159 const int da
[5] = {0};
166 #pragma omp parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
167 for (i
= 0; i
< argc
; ++i
)
169 #pragma omp parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170 for (i
= 0; i
< argc
; ++i
)
172 #pragma omp parallel for simd firstprivate() // expected-error {{expected expression}}
173 for (i
= 0; i
< argc
; ++i
)
175 #pragma omp parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
176 for (i
= 0; i
< argc
; ++i
)
178 #pragma omp parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
179 for (i
= 0; i
< argc
; ++i
)
181 #pragma omp parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
182 for (i
= 0; i
< argc
; ++i
)
184 #pragma omp parallel for simd firstprivate(argc, z)
185 for (i
= 0; i
< argc
; ++i
)
187 #pragma omp parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
188 for (i
= 0; i
< argc
; ++i
)
190 #pragma omp parallel for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
191 for (i
= 0; i
< argc
; ++i
)
193 #pragma omp parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
194 for (i
= 0; i
< argc
; ++i
)
196 #pragma omp parallel for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
197 for (i
= 0; i
< argc
; ++i
)
199 #pragma omp parallel for simd firstprivate(ba) // OK
200 for (i
= 0; i
< argc
; ++i
)
202 #pragma omp parallel for simd firstprivate(ca) // OK
203 for (i
= 0; i
< argc
; ++i
)
205 #pragma omp parallel for simd firstprivate(da) // OK
206 for (i
= 0; i
< argc
; ++i
)
209 #pragma omp parallel for simd firstprivate(xa) // OK
210 for (i
= 0; i
< argc
; ++i
)
212 #pragma omp parallel for simd firstprivate(S2::S2s) // OK
213 for (i
= 0; i
< argc
; ++i
)
215 #pragma omp parallel for simd firstprivate(S2::S2sc) // OK
216 for (i
= 0; i
< argc
; ++i
)
218 #pragma omp parallel for simd safelen(5)
219 for (i
= 0; i
< argc
; ++i
)
221 #pragma omp parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
222 for (i
= 0; i
< argc
; ++i
)
224 #pragma omp parallel for simd firstprivate(m) // OK
225 for (i
= 0; i
< argc
; ++i
)
227 #pragma omp parallel for simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
228 for (i
= 0; i
< argc
; ++i
)
230 #pragma omp parallel for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
231 for (i
= 0; i
< argc
; ++i
)
233 #pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
234 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
236 #pragma omp parallel for simd firstprivate(xa) // OK: may be firstprivate
237 for (i
= 0; i
< argc
; ++i
)
239 #pragma omp parallel for simd firstprivate(j)
240 for (i
= 0; i
< argc
; ++i
)
242 #pragma omp parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
243 for (i
= 0; i
< argc
; ++i
)
245 #pragma omp parallel for simd lastprivate(n) firstprivate(n) // OK
246 for (i
= 0; i
< argc
; ++i
)
252 #pragma omp parallel for simd firstprivate(i)
253 for (int k
= 0; k
< argc
; ++k
) {
258 #pragma omp parallel private(i)
259 #pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
260 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
262 #pragma omp parallel reduction(+ : i)
263 #pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
264 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
267 #pragma omp parallel for simd firstprivate(si) // OK
268 for (i
= 0; i
< argc
; ++i
)
271 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}