1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 #pragma omp requires dynamic_allocators
6 typedef void **omp_allocator_handle_t
;
7 extern const omp_allocator_handle_t omp_null_allocator
;
8 extern const omp_allocator_handle_t omp_default_mem_alloc
;
9 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
10 extern const omp_allocator_handle_t omp_const_mem_alloc
;
11 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
12 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
13 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
14 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
15 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
20 bool foobool(int argc
) {
25 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
26 #pragma omp target parallel for firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
27 for (int i
= 0; i
< 10; ++i
)
31 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
38 S2(const S2
&s2
) : a(s2
.a
) {}
40 static const float S2sc
;
42 const float S2::S2sc
= 0;
47 S3
&operator=(const S3
&s3
);
51 S3(const S3
&s3
) : a(s3
.a
) {}
59 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
66 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
77 S6(const S6
&s6
) : a(s6
.a
) {}
82 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
84 template <class I
, class C
>
85 int foomain(int argc
, char **argv
) {
90 #pragma omp target parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
91 for (int k
= 0; k
< argc
; ++k
)
93 #pragma omp target parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
94 for (int k
= 0; k
< argc
; ++k
)
96 #pragma omp target parallel for firstprivate() // expected-error {{expected expression}}
97 for (int k
= 0; k
< argc
; ++k
)
99 #pragma omp target parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
100 for (int k
= 0; k
< argc
; ++k
)
102 #pragma omp target parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (int k
= 0; k
< argc
; ++k
)
105 #pragma omp target parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
106 for (int k
= 0; k
< argc
; ++k
)
108 #pragma omp target 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 '('}}
109 for (int k
= 0; k
< argc
; ++k
)
111 #pragma omp target parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
112 for (int k
= 0; k
< argc
; ++k
)
114 #pragma omp target parallel for firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
115 for (int k
= 0; k
< argc
; ++k
)
117 #pragma omp target parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
118 for (int k
= 0; k
< argc
; ++k
)
120 #pragma omp target parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
121 for (int k
= 0; k
< argc
; ++k
)
123 #pragma omp target parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
124 for (int k
= 0; k
< argc
; ++k
)
130 #pragma omp target parallel for firstprivate(i)
131 for (int k
= 0; k
< argc
; ++k
) {
136 #pragma omp parallel shared(i)
137 #pragma omp parallel private(i)
138 #pragma omp target parallel for firstprivate(j)
139 for (int k
= 0; k
< argc
; ++k
)
141 #pragma omp target parallel for firstprivate(i)
142 for (int k
= 0; k
< argc
; ++k
)
144 #pragma omp target parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
145 for (i
= 0; i
< argc
; ++i
)
147 #pragma omp parallel private(i)
148 #pragma omp target parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
149 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
151 #pragma omp parallel reduction(+ : i)
152 #pragma omp target parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
153 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
160 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
166 int main(int argc
, char **argv
) {
168 const int da
[5] = {0};
175 #pragma omp target parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
176 for (i
= 0; i
< argc
; ++i
)
178 #pragma omp target parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
179 for (i
= 0; i
< argc
; ++i
)
181 #pragma omp target parallel for firstprivate() // expected-error {{expected expression}}
182 for (i
= 0; i
< argc
; ++i
)
184 #pragma omp target parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
185 for (i
= 0; i
< argc
; ++i
)
187 #pragma omp target parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
188 for (i
= 0; i
< argc
; ++i
)
190 #pragma omp target parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
191 for (i
= 0; i
< argc
; ++i
)
193 #pragma omp target parallel for allocate(omp_thread_mem_alloc: argc) firstprivate(argc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel for' directive}}
194 for (i
= 0; i
< argc
; ++i
)
196 #pragma omp target parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
197 for (i
= 0; i
< argc
; ++i
)
199 #pragma omp target parallel for firstprivate(z, a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
200 for (i
= 0; i
< argc
; ++i
)
202 #pragma omp target parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
203 for (i
= 0; i
< argc
; ++i
)
205 #pragma omp target parallel for firstprivate(2 * 2) // expected-error {{expected variable name}}
206 for (i
= 0; i
< argc
; ++i
)
208 #pragma omp target parallel for firstprivate(ba) // OK
209 for (i
= 0; i
< argc
; ++i
)
211 #pragma omp target parallel for firstprivate(ca) // OK
212 for (i
= 0; i
< argc
; ++i
)
214 #pragma omp target parallel for firstprivate(da) // OK
215 for (i
= 0; i
< argc
; ++i
)
218 #pragma omp target parallel for firstprivate(xa) // OK
219 for (i
= 0; i
< argc
; ++i
)
221 #pragma omp target parallel for firstprivate(S2::S2s) // OK
222 for (i
= 0; i
< argc
; ++i
)
224 #pragma omp target parallel for firstprivate(S2::S2sc) // OK
225 for (i
= 0; i
< argc
; ++i
)
227 #pragma omp target parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp target parallel for'}}
228 for (i
= 0; i
< argc
; ++i
)
230 #pragma omp target parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
231 for (i
= 0; i
< argc
; ++i
)
233 #pragma omp target parallel for firstprivate(m) // OK
234 for (i
= 0; i
< argc
; ++i
)
236 #pragma omp target parallel for firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
237 for (i
= 0; i
< argc
; ++i
)
239 #pragma omp target parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
240 for (i
= 0; i
< argc
; ++i
)
242 #pragma omp target parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
243 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
245 #pragma omp parallel shared(xa)
246 #pragma omp target parallel for firstprivate(xa) // OK: may be firstprivate
247 for (i
= 0; i
< argc
; ++i
)
249 #pragma omp target parallel for firstprivate(j)
250 for (i
= 0; i
< argc
; ++i
)
252 #pragma omp target parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
253 for (i
= 0; i
< argc
; ++i
)
255 #pragma omp target parallel for lastprivate(n) firstprivate(n) // OK
256 for (i
= 0; i
< argc
; ++i
)
262 #pragma omp target parallel for firstprivate(i)
263 for (int k
= 0; k
< argc
; ++k
) {
268 #pragma omp parallel private(i)
269 #pragma omp target parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
270 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
272 #pragma omp parallel reduction(+ : i)
273 #pragma omp target parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
274 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for' directive may not be firstprivate, predetermined as private}}
277 #pragma omp target parallel for firstprivate(si) // OK
278 for (i
= 0; i
< argc
; ++i
)
281 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}