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
;
17 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
36 S4(); // expected-note {{implicitly declared private here}}
40 #pragma omp target private(a) private(this->a)
41 for (int k
= 0; k
< v
; ++k
)
47 S5() : a(0) {} // expected-note {{implicitly declared private here}}
51 S5
&operator=(S5
&s
) {
52 #pragma omp target private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
53 for (int k
= 0; k
< s
.a
; ++k
) // expected-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
66 #pragma omp target private(a) private(this->a) allocate(omp_thread_mem_alloc: a) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target' directive}}
67 for (int k
= 0; k
< v
; ++k
)
70 S6
&operator=(S6
&s
) {
71 #pragma omp target private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
72 for (int k
= 0; k
< s
.a
; ++k
)
85 #pragma omp target private(a) private(this->a) private(T::a)
86 for (int k
= 0; k
< a
.a
; ++k
)
89 S7
&operator=(S7
&s
) {
90 #pragma omp target private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
91 for (int k
= 0; k
< s
.a
.a
; ++k
)
98 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
100 template <class I
, class C
>
101 int foomain(I argc
, C
**argv
) {
106 #pragma omp target private // expected-error {{expected '(' after 'private'}}
108 #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
110 #pragma omp target private() // expected-error {{expected expression}}
112 #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
114 #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
116 #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
118 #pragma omp target private(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 '('}}
120 #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}}
122 #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
124 #pragma omp target private(argv[1]) // expected-error {{expected variable name}}
126 #pragma omp target private(e, g)
128 #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
130 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
136 #pragma omp parallel shared(i)
137 #pragma omp parallel private(i)
138 #pragma omp target private(j)
140 #pragma omp target private(i)
147 #pragma omp target private(a)
153 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
159 int main(int argc
, char **argv
) {
162 S6
<float> s6(0.0) , s6_0(1.0); // expected-note {{in instantiation of member function 'S6<float>::S6' requested here}}
163 S7
<S6
<float> > s7(0.0) , s7_0(1.0);
166 #pragma omp target private // expected-error {{expected '(' after 'private'}}
168 #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170 #pragma omp target private() // expected-error {{expected expression}}
172 #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
174 #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
176 #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
178 #pragma omp target private(argc)
180 #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}}
182 #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
184 #pragma omp target private(argv[1]) // expected-error {{expected variable name}}
186 #pragma omp target private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
188 #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
190 #pragma omp target private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
192 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
197 #pragma omp parallel shared(i)
198 #pragma omp parallel private(i)
199 #pragma omp target private(j)
201 #pragma omp target private(i)
204 #pragma omp target private(si) // OK
206 #pragma omp target map(i) private(i) // expected-error {{private variable cannot be in a map clause in '#pragma omp target' directive}}
208 s6
= s6_0
; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
209 s7
= s7_0
; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}}
210 return foomain(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}