1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 int fp
, fp1
; // expected-note {{initialize the variable 'fp' to silence this warning}} expected-note {{initialize the variable 'fp1' to silence this warning}}
7 #pragma omp target firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
8 for (int i
= 0; i
< 10; ++i
)
9 ++fp1
; // expected-warning {{variable 'fp1' is uninitialized when used here}}
12 typedef void **omp_allocator_handle_t
;
13 extern const omp_allocator_handle_t omp_null_allocator
;
14 extern const omp_allocator_handle_t omp_default_mem_alloc
;
15 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
16 extern const omp_allocator_handle_t omp_const_mem_alloc
;
17 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
18 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
19 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
20 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
21 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
23 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
46 #pragma omp target firstprivate(a) firstprivate(this->a)
47 for (int k
= 0; k
< v
; ++k
)
57 S5
&operator=(S5
&s
) {
58 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}
59 for (int k
= 0; k
< s
.a
; ++k
) // expected-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
72 #pragma omp target firstprivate(a) firstprivate(this->a)
73 for (int k
= 0; k
< v
; ++k
)
76 S6
&operator=(S6
&s
) {
77 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}
78 for (int k
= 0; k
< s
.a
; ++k
)
91 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(T::a)
92 for (int k
= 0; k
< a
.a
; ++k
)
95 S7
&operator=(S7
&s
) {
96 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) firstprivate(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
97 for (int k
= 0; k
< s
.a
.a
; ++k
)
104 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
106 template <class I
, class C
>
107 int foomain(I argc
, C
**argv
) {
112 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}
114 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
116 #pragma omp target firstprivate() // expected-error {{expected expression}}
118 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
120 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
122 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
124 #pragma omp target 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 '('}}
126 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
128 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
130 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}}
132 #pragma omp target firstprivate(e, g) allocate(omp_thread_mem_alloc: e) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target' directive}} expected-error {{allocator must be specified in the 'uses_allocators' clause}}
134 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
136 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
142 #pragma omp parallel shared(i, z)
143 #pragma omp parallel firstprivate(i, z)
144 #pragma omp target firstprivate(j)
146 #pragma omp target firstprivate(i)
153 #pragma omp target firstprivate(a)
159 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
165 int main(int argc
, char **argv
) {
168 S6
<float> s6(0.0) , s6_0(1.0);
169 S7
<S6
<float> > s7(0.0) , s7_0(1.0);
172 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}
174 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
176 #pragma omp target firstprivate() // expected-error {{expected expression}}
178 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
180 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
182 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
184 #pragma omp target firstprivate(argc, z)
186 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
188 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
190 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}}
192 #pragma omp target firstprivate(e, g)
194 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
196 #pragma omp target firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
198 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
203 #pragma omp parallel shared(i)
204 #pragma omp parallel firstprivate(i)
205 #pragma omp target firstprivate(j)
207 #pragma omp target firstprivate(i)
210 #pragma omp target firstprivate(si) // OK
212 #pragma omp target map(i) firstprivate(i) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}}
214 s6
= s6_0
; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
215 s7
= s7_0
; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}}
216 return foomain(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}