1 // RUN: %clang_cc1 -verify -fopenmp -fsyntax-only %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -fsyntax-only %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -fsyntax-only %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++11 -fsyntax-only %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd -fsyntax-only %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -fsyntax-only %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -fsyntax-only %s -Wuninitialized
8 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++11 -fsyntax-only %s -Wuninitialized
10 typedef void **omp_allocator_handle_t
;
11 extern const omp_allocator_handle_t omp_null_allocator
;
12 extern const omp_allocator_handle_t omp_default_mem_alloc
;
13 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
14 extern const omp_allocator_handle_t omp_const_mem_alloc
;
15 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
16 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
17 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
18 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
19 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
22 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
23 [[omp::directive(taskloop
reduction(+:fp
))]] // expected-warning {{variable 'fp' is uninitialized when used here}}
24 for (int i
= 0; i
< 10; ++i
)
31 bool foobool(int argc
) {
35 void foobar(int &ref
) {
36 [[omp::directive(taskloop
reduction(+:ref
))]]
37 for (int i
= 0; i
< 10; ++i
)
41 struct S1
; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
45 S2
&operator+(const S2
&arg
) { return (*this); } // expected-note 3 {{implicitly declared private here}}
49 S2(S2
&s2
) : a(s2
.a
) {}
50 static float S2s
; // expected-note 2 {{static data member is predetermined as shared}}
51 static const float S2sc
; // expected-note 2 {{'S2sc' declared here}}
53 const float S2::S2sc
= 0;
54 S2 b
; // expected-note 3 {{'b' defined here}}
55 const S2 ba
[5]; // expected-note 2 {{'ba' defined here}}
62 S3(const S3
&s3
) : a(s3
.a
) {}
63 S3
operator+(const S3
&arg1
) { return arg1
; }
65 int operator+(const S3
&arg1
, const S3
&arg2
) { return 5; }
66 S3 c
; // expected-note 3 {{'c' defined here}}
67 const S3 ca
[5]; // expected-note 2 {{'ca' defined here}}
68 extern const int f
; // expected-note 4 {{'f' declared here}}
71 S4(); // expected-note {{implicitly declared private here}}
73 S4
&operator+(const S4
&arg
) { return (*this); }
78 S4
&operator&=(S4
&arg1
, S4
&arg2
) { return arg1
; }
81 S5() : a(0) {} // expected-note {{implicitly declared private here}}
82 S5(const S5
&s5
) : a(s5
.a
) {}
83 S5
&operator+(const S5
&arg
);
88 class S6
{ // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
89 #if __cplusplus >= 201103L // C++11 or later
90 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
96 operator int() { return 6; }
102 [[omp::directive(taskloop
reduction(+:a
))]] // expected-error {{expected addressable reduction item for the task-based directives}}
103 for (int i
= 0; i
< 10; ++i
)
109 [[omp::directive(threadprivate(h
))]]; // expected-note 2 {{defined as threadprivate or thread local}}
111 template <class T
> // expected-note {{declared here}}
113 const T d
= T(); // expected-note 4 {{'d' defined here}}
114 const T da
[5] = {T()}; // expected-note 2 {{'da' defined here}}
117 T
&j
= i
; // expected-note 4 {{'j' defined here}}
118 S3
&p
= k
; // expected-note 2 {{'p' defined here}}
119 const T
&r
= da
[(int)i
]; // expected-note 2 {{'r' defined here}}
120 T
&q
= qa
[(int)i
]; // expected-note 2 {{'q' defined here}}
122 [[omp::directive(taskloop reduction
)]] // expected-error {{expected '(' after 'reduction'}}
123 for (int i
= 0; i
< 10; ++i
)
125 [[omp::directive(taskloop reduction
+)]] // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
126 for (int i
= 0; i
< 10; ++i
)
128 [[omp::directive(taskloop
reduction())]] // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
129 for (int i
= 0; i
< 10; ++i
)
131 [[omp::directive(taskloop
reduction(*))]] // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
132 for (int i
= 0; i
< 10; ++i
)
134 [[omp::directive(taskloop
reduction(\
))]] // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
135 for (int i
= 0; i
< 10; ++i
)
137 [[omp::directive(taskloop
reduction(foo
: argc
))]] //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}}
138 for (int i
= 0; i
< 10; ++i
)
140 [[omp::directive(taskloop
reduction(^ : T
))]] // expected-error {{'T' does not refer to a value}}
141 for (int i
= 0; i
< 10; ++i
)
143 [[omp::directive(taskloop
reduction(+ : z
, a
, b
, c
, d
, f
))]] // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
144 for (int i
= 0; i
< 10; ++i
)
146 [[omp::directive(taskloop
reduction(min
: a
, b
, c
, d
, f
))]] // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
147 for (int i
= 0; i
< 10; ++i
)
149 [[omp::directive(taskloop
reduction(max
: h
.b
))]] // expected-error {{expected variable name, array element or array section}}
150 for (int i
= 0; i
< 10; ++i
)
152 [[omp::directive(taskloop
reduction(+ : ba
))]] // expected-error {{const-qualified variable cannot be reduction}}
153 for (int i
= 0; i
< 10; ++i
)
155 [[omp::directive(taskloop
reduction(* : ca
))]] // expected-error {{const-qualified variable cannot be reduction}}
156 for (int i
= 0; i
< 10; ++i
)
158 [[omp::directive(taskloop
reduction(- : da
))]] // expected-error 2 {{const-qualified variable cannot be reduction}} omp52-warning 3 {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
159 for (int i
= 0; i
< 10; ++i
)
161 [[omp::directive(taskloop
reduction(^ : fl
))]] // expected-error {{invalid operands to binary expression ('float' and 'float')}}
162 for (int i
= 0; i
< 10; ++i
)
164 [[omp::directive(taskloop
reduction(&& : S2::S2s
))]] // expected-error {{shared variable cannot be reduction}}
165 for (int i
= 0; i
< 10; ++i
)
167 [[omp::directive(taskloop
reduction(&& : S2::S2sc
))]] // expected-error {{const-qualified variable cannot be reduction}}
168 for (int i
= 0; i
< 10; ++i
)
170 [[omp::directive(taskloop
reduction(+ : h
, k
))]] // expected-error {{threadprivate or thread local variable cannot be reduction}}
171 for (int i
= 0; i
< 10; ++i
)
173 [[omp::directive(taskloop
reduction(+ : o
))]] // expected-error 2 {{no viable overloaded '='}}
174 for (int i
= 0; i
< 10; ++i
)
176 [[omp::directive(taskloop
private(i
), reduction(+ : j
), reduction(+ : q
))]] // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
177 for (int i
= 0; i
< 10; ++i
)
179 [[omp::sequence(directive(parallel
private(k
)), directive(taskloop
reduction(+ : p
), reduction(+ : p
)))]] // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
180 for (int i
= 0; i
< 10; ++i
)
182 [[omp::directive(taskloop
reduction(+ : p
), reduction(+ : p
))]] // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
183 for (int i
= 0; i
< 10; ++i
)
185 [[omp::directive(taskloop
reduction(+ : r
))]] // expected-error 2 {{const-qualified variable cannot be reduction}}
186 for (int i
= 0; i
< 10; ++i
)
188 [[omp::sequence(directive(parallel
shared(i
)), directive(parallel
reduction(min
: i
)), directive(taskloop
reduction(max
: j
)))]] // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
189 for (int i
= 0; i
< 10; ++i
)
191 [[omp::sequence(directive(parallel
private(fl
)), directive(taskloop
reduction(+ : fl
) allocate(omp_thread_mem_alloc
: fl
)))]] // expected-warning 2 {{allocator with the 'thread' trait access has unspecified behavior on 'taskloop' directive}}
192 for (int i
= 0; i
< 10; ++i
)
194 [[omp::sequence(directive(parallel
reduction(* : fl
)), directive(taskloop
reduction(+ : fl
)))]]
195 for (int i
= 0; i
< 10; ++i
)
203 [[omp::directive(threadprivate(x
))]]; // expected-note {{defined as threadprivate or thread local}}
209 int main(int argc
, char **argv
) {
210 const int d
= 5; // expected-note 2 {{'d' defined here}}
211 const int da
[5] = {0}; // expected-note {{'da' defined here}}
216 int &j
= i
; // expected-note 2 {{'j' defined here}}
217 S3
&p
= k
; // expected-note 2 {{'p' defined here}}
218 const int &r
= da
[i
]; // expected-note {{'r' defined here}}
219 int &q
= qa
[i
]; // expected-note {{'q' defined here}}
221 [[omp::directive(taskloop reduction
)]] // expected-error {{expected '(' after 'reduction'}}
222 for (int i
= 0; i
< 10; ++i
)
224 [[omp::directive(taskloop reduction
+)]] // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
225 for (int i
= 0; i
< 10; ++i
)
227 [[omp::directive(taskloop
reduction())]] // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
228 for (int i
= 0; i
< 10; ++i
)
230 [[omp::directive(taskloop
reduction(*))]] // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
231 for (int i
= 0; i
< 10; ++i
)
233 [[omp::directive(taskloop
reduction(\
))]] // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
234 for (int i
= 0; i
< 10; ++i
)
236 [[omp::directive(taskloop
reduction(~ : argc
))]] // expected-error {{expected unqualified-id}}
237 for (int i
= 0; i
< 10; ++i
)
239 [[omp::directive(taskloop
reduction(&& : argc
, z
))]]
240 for (int i
= 0; i
< 10; ++i
)
242 [[omp::directive(taskloop
reduction(^ : S1
))]] // expected-error {{'S1' does not refer to a value}}
243 for (int i
= 0; i
< 10; ++i
)
245 [[omp::directive(taskloop
reduction(+ : a
, b
, c
, d
, f
))]] // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
246 for (int i
= 0; i
< 10; ++i
)
248 [[omp::directive(taskloop
reduction(min
: a
, b
, c
, d
, f
))]] // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
249 for (int i
= 0; i
< 10; ++i
)
251 [[omp::directive(taskloop
reduction(max
: h
.b
))]] // expected-error {{expected variable name, array element or array section}}
252 for (int i
= 0; i
< 10; ++i
)
254 [[omp::directive(taskloop
reduction(+ : ba
))]] // expected-error {{const-qualified variable cannot be reduction}}
255 for (int i
= 0; i
< 10; ++i
)
257 [[omp::directive(taskloop
reduction(* : ca
))]] // expected-error {{const-qualified variable cannot be reduction}}
258 for (int i
= 0; i
< 10; ++i
)
260 [[omp::directive(taskloop
reduction(- : da
))]] // expected-error {{const-qualified variable cannot be reduction}} omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
261 for (int i
= 0; i
< 10; ++i
)
263 [[omp::directive(taskloop
reduction(^ : fl
))]] // expected-error {{invalid operands to binary expression ('float' and 'float')}}
264 for (int i
= 0; i
< 10; ++i
)
266 [[omp::directive(taskloop
reduction(&& : S2::S2s
))]] // expected-error {{shared variable cannot be reduction}}
267 for (int i
= 0; i
< 10; ++i
)
269 [[omp::directive(taskloop
reduction(&& : S2::S2sc
))]] // expected-error {{const-qualified variable cannot be reduction}}
270 for (int i
= 0; i
< 10; ++i
)
272 [[omp::directive(taskloop
reduction(& : e
, g
))]] // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
273 for (int i
= 0; i
< 10; ++i
)
275 [[omp::directive(taskloop
reduction(+ : h
, k
, B::x
))]] // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
276 for (int i
= 0; i
< 10; ++i
)
278 [[omp::directive(taskloop
reduction(+ : o
))]] // expected-error {{no viable overloaded '='}}
279 for (int i
= 0; i
< 10; ++i
)
281 [[omp::directive(taskloop
private(i
), reduction(+ : j
), reduction(+ : q
))]] // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
282 for (int i
= 0; i
< 10; ++i
)
284 [[omp::sequence(directive(parallel
private(k
)), directive(taskloop
reduction(+ : p
), reduction(+ : p
)))]] // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
285 for (int i
= 0; i
< 10; ++i
)
287 [[omp::directive(taskloop
reduction(+ : p
), reduction(+ : p
))]] // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
288 for (int i
= 0; i
< 10; ++i
)
290 [[omp::directive(taskloop
reduction(+ : r
))]] // expected-error {{const-qualified variable cannot be reduction}}
291 for (int i
= 0; i
< 10; ++i
)
293 [[omp::sequence(directive(parallel
shared(i
)), directive(parallel
reduction(min
: i
)), directive(taskloop
reduction(max
: j
)))]] // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
294 for (int i
= 0; i
< 10; ++i
)
296 [[omp::sequence(directive(parallel
private(fl
)), directive(taskloop
reduction(+ : fl
)))]]
297 for (int i
= 0; i
< 10; ++i
)
299 [[omp::sequence(directive(parallel
reduction(* : fl
)), directive(taskloop
reduction(+ : fl
)))]]
300 for (int i
= 0; i
< 10; ++i
)
303 [[omp::directive(taskloop
reduction(+ : m
))]] // OK
304 for (int i
= 0; i
< 10; ++i
)
306 [[omp::directive(taskloop
reduction(task
, + : m
))]] // expected-error {{'reduction' clause with 'task' modifier allowed only on non-simd parallel or worksharing constructs}}
307 for (int i
= 0; i
< 10; ++i
)
309 [[omp::directive(taskloop nogroup
reduction(+ : m
))]] // expected-error {{'reduction' clause cannot be used with 'nogroup' clause}}
310 for (int i
= 0; i
< 10; ++i
)
313 return tmain(argc
) + tmain(fl
); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}