1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 150 -o - %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 150 -o - %s
4 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 150 -o - %s
5 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++98 -ferror-limit 150 -o - %s
6 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -std=c++11 -ferror-limit 150 -o - %s
8 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 150 -o - %s
9 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s
10 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -ferror-limit 150 -o - %s
11 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -ferror-limit 150 -o - %s
12 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++98 -ferror-limit 150 -o - %s
13 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -std=c++11 -ferror-limit 150 -o - %s
14 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
16 typedef void **omp_allocator_handle_t
;
17 extern const omp_allocator_handle_t omp_null_allocator
;
18 extern const omp_allocator_handle_t omp_default_mem_alloc
;
19 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
20 extern const omp_allocator_handle_t omp_const_mem_alloc
;
21 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
22 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
23 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
24 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
25 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
30 bool foobool(int argc
) {
34 void foobar(int &ref
) {
35 #pragma omp taskgroup task_reduction(+:ref)
36 #pragma omp task in_reduction(+:ref) allocate(omp_thread_mem_alloc: ref) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'task' directive}}
40 void foobar1(int &ref
) {
41 #pragma omp taskgroup task_reduction(+:ref)
42 #pragma omp task in_reduction(-:ref) // omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
46 #pragma omp declare reduction (red:int:omp_out += omp_in)
48 void foobar2(int &ref
) {
49 #pragma omp taskgroup task_reduction(+:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
50 #pragma omp task in_reduction(red:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
54 void foobar3(int &ref
) {
55 #pragma omp taskgroup task_reduction(red:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
56 #pragma omp task in_reduction(min:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
60 void foobar4(int &ref
) {
61 #pragma omp task in_reduction(min:ref)
65 struct S1
; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
69 S2
&operator+(const S2
&arg
) { return (*this); } // expected-note 3 {{implicitly declared private here}}
73 S2(S2
&s2
) : a(s2
.a
) {}
74 static float S2s
; // expected-note 2 {{static data member is predetermined as shared}}
75 static const float S2sc
; // expected-note 2 {{'S2sc' declared here}}
77 const float S2::S2sc
= 0;
78 S2 b
; // expected-note 3 {{'b' defined here}}
79 const S2 ba
[5]; // expected-note 2 {{'ba' defined here}}
86 S3(const S3
&s3
) : a(s3
.a
) {}
87 S3
operator+(const S3
&arg1
) { return arg1
; }
89 int operator+(const S3
&arg1
, const S3
&arg2
) { return 5; }
90 S3 c
; // expected-note 3 {{'c' defined here}}
91 const S3 ca
[5]; // expected-note 2 {{'ca' defined here}}
92 extern const int f
; // expected-note 4 {{'f' declared here}}
95 S4(); // expected-note {{implicitly declared private here}}
97 S4
&operator+(const S4
&arg
) { return (*this); }
102 S4
&operator&=(S4
&arg1
, S4
&arg2
) { return arg1
; }
105 S5() : a(0) {} // expected-note {{implicitly declared private here}}
106 S5(const S5
&s5
) : a(s5
.a
) {}
107 S5
&operator+(const S5
&arg
);
112 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}}
113 #if __cplusplus >= 201103L // C++11 or later
114 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
120 operator int() { return 6; }
124 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
126 template <class T
> // expected-note {{declared here}}
128 const T d
= T(); // expected-note 4 {{'d' defined here}}
129 const T da
[5] = {T()}; // expected-note 2 {{'da' defined here}}
132 T
&j
= i
; // expected-note 2 {{'j' defined here}}
133 S3
&p
= k
; // expected-note 2 {{'p' defined here}}
134 const T
&r
= da
[(int)i
]; // expected-note 2 {{'r' defined here}}
137 #pragma omp taskgroup task_reduction(+:argc)
138 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
140 #pragma omp taskgroup task_reduction(+:argc)
141 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
143 #pragma omp taskgroup task_reduction(+:argc)
144 #pragma omp task in_reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
146 #pragma omp taskgroup task_reduction(+:argc)
147 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
149 #pragma omp taskgroup task_reduction(+:argc)
150 #pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
152 #pragma omp taskgroup task_reduction(+:argc)
153 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
155 #pragma omp taskgroup task_reduction(+:argc)
156 #pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
158 #pragma omp taskgroup task_reduction(&:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
159 #pragma omp task in_reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
161 #pragma omp taskgroup task_reduction(|:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
162 #pragma omp task in_reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
164 #pragma omp task in_reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
166 #pragma omp task in_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'}}
168 #pragma omp taskgroup task_reduction(&&:argc)
169 #pragma omp task in_reduction(&& : argc)
171 #pragma omp task in_reduction(^ : T) // expected-error {{'T' does not refer to a value}}
173 #pragma omp taskgroup task_reduction(+:c)
174 #pragma omp task in_reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be in_reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
176 #pragma omp task in_reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'in_reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be in_reduction}}
178 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
180 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified variable cannot be in_reduction}}
182 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified variable cannot be in_reduction}}
184 #pragma omp task in_reduction(- : da) // expected-error 2 {{const-qualified variable cannot be in_reduction}} omp52-warning 3 {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
186 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
188 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
190 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be in_reduction}}
192 #pragma omp taskgroup task_reduction(+:k)
193 #pragma omp task in_reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
195 #pragma omp task in_reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
197 #pragma omp parallel private(k)
198 #pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
200 #pragma omp taskgroup task_reduction(+:p)
201 #pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'in_reduction' clause}} expected-note 2 {{previously referenced here}}
203 #pragma omp task in_reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be in_reduction}}
205 #pragma omp parallel shared(i)
206 #pragma omp parallel reduction(min : i)
207 #pragma omp task in_reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
209 #pragma omp taskgroup task_reduction(+:fl)
210 #pragma omp task in_reduction(+ : fl)
213 #pragma omp for reduction(- : fl) // omp52-warning 3 {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
214 for (int i
= 0; i
< 10; ++i
)
215 #pragma omp taskgroup task_reduction(+:fl)
216 #pragma omp task in_reduction(+ : fl)
224 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
230 int main(int argc
, char **argv
) {
231 const int d
= 5; // expected-note 2 {{'d' defined here}}
232 const int da
[5] = {0}; // expected-note {{'da' defined here}}
237 int &j
= i
; // expected-note {{'j' defined here}}
238 S3
&p
= k
; // expected-note 2 {{'p' defined here}}
239 const int &r
= da
[i
]; // expected-note {{'r' defined here}}
242 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
244 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
246 #pragma omp task in_reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
248 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
250 #pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
252 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
254 #pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
256 #pragma omp task in_reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
258 #pragma omp taskgroup task_reduction(|:argc)
260 #pragma omp taskgroup task_reduction(+:argc) // expected-note {{previously marked as task_reduction with different reduction operation}}
262 #pragma omp task in_reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
265 #pragma omp task in_reduction(| : 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 '('}}
268 #pragma omp task in_reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
270 #pragma omp task in_reduction(~ : argc) // expected-error {{expected unqualified-id}}
272 #pragma omp taskgroup task_reduction(&&:argc)
273 #pragma omp task in_reduction(&& : argc)
275 #pragma omp task in_reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
277 #pragma omp taskgroup task_reduction(+:c)
278 #pragma omp task in_reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be in_reduction}} expected-error {{'operator+' is a private member of 'S2'}}
280 #pragma omp task in_reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'in_reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be in_reduction}}
282 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
284 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified variable cannot be in_reduction}}
286 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified variable cannot be in_reduction}}
288 #pragma omp task in_reduction(- : da) // expected-error {{const-qualified variable cannot be in_reduction}} omp52-warning {{minus(-) operator for reductions is deprecated; use + or user defined reduction instead}}
290 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
292 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
294 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be in_reduction}}
296 #pragma omp task in_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')}}
298 #pragma omp taskgroup task_reduction(+:k)
299 #pragma omp task in_reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
301 #pragma omp task in_reduction(+ : o) // expected-error {{no viable overloaded '='}}
303 #pragma omp parallel private(k)
304 #pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
306 #pragma omp taskgroup task_reduction(+:p)
307 #pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'in_reduction' clause}} expected-note {{previously referenced here}}
309 #pragma omp task in_reduction(+ : r) // expected-error {{const-qualified variable cannot be in_reduction}}
311 #pragma omp parallel shared(i)
312 #pragma omp parallel reduction(min : i)
313 #pragma omp task in_reduction(max : j) // expected-error {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
316 #pragma omp for private(fl)
317 for (int i
= 0; i
< 10; ++i
)
318 #pragma omp taskgroup task_reduction(+:fl)
319 #pragma omp task in_reduction(+ : fl)
321 #pragma omp taskgroup task_reduction(+:fl)
322 #pragma omp task in_reduction(+ : fl)
325 #pragma omp taskgroup task_reduction(+:m)
326 #pragma omp task in_reduction(+ : m) // OK
329 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}}