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
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 150 -o - %s
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -ferror-limit 150 -o - %s
8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
13 bool foobool(int argc) {
17 void foobar(int &ref) {
18 #pragma omp taskgroup task_reduction(+:ref)
19 #pragma omp task in_reduction(+:ref)
23 void foobar1(int &ref) {
24 #pragma omp taskgroup task_reduction(+:ref)
25 #pragma omp task in_reduction(-:ref)
29 #pragma omp declare reduction (red:int:omp_out += omp_in)
31 void foobar2(int &ref) {
32 #pragma omp taskgroup task_reduction(+:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
33 #pragma omp task in_reduction(red:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
37 void foobar3(int &ref) {
38 #pragma omp taskgroup task_reduction(red:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
39 #pragma omp task in_reduction(min:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
43 void foobar4(int &ref) {
44 #pragma omp task in_reduction(min:ref) // expected-error {{in_reduction variable must appear in a task_reduction clause}}
48 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
52 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
56 S2(S2 &s2) : a(s2.a) {}
57 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
58 static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
60 const float S2::S2sc = 0;
61 S2 b; // expected-note 3 {{'b' defined here}}
62 const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
69 S3(const S3 &s3) : a(s3.a) {}
70 S3 operator+(const S3 &arg1) { return arg1; }
72 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
73 S3 c; // expected-note 3 {{'c' defined here}}
74 const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
75 extern const int f; // expected-note 4 {{'f' declared here}}
78 S4(); // expected-note {{implicitly declared private here}}
80 S4 &operator+(const S4 &arg) { return (*this); }
85 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
88 S5() : a(0) {} // expected-note {{implicitly declared private here}}
89 S5(const S5 &s5) : a(s5.a) {}
90 S5 &operator+(const S5 &arg);
95 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}}
96 #if __cplusplus >= 201103L // C++11 or later
97 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
103 operator int() { return 6; }
107 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
109 template <class T> // expected-note {{declared here}}
111 const T d = T(); // expected-note 4 {{'d' defined here}}
112 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
115 T &j = i; // expected-note 2 {{'j' defined here}}
116 S3 &p = k; // expected-note 2 {{'p' defined here}}
117 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
120 #pragma omp taskgroup task_reduction(+:argc)
121 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
123 #pragma omp taskgroup task_reduction(+:argc)
124 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
126 #pragma omp taskgroup task_reduction(+:argc)
127 #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 '('}}
129 #pragma omp taskgroup task_reduction(+:argc)
130 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
132 #pragma omp taskgroup task_reduction(+:argc)
133 #pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
135 #pragma omp taskgroup task_reduction(+:argc)
136 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
138 #pragma omp taskgroup task_reduction(+:argc)
139 #pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
141 #pragma omp taskgroup task_reduction(&:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
142 #pragma omp task in_reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
144 #pragma omp taskgroup task_reduction(|:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
145 #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')}}
147 #pragma omp task in_reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
149 #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'}}
151 #pragma omp taskgroup task_reduction(&&:argc)
152 #pragma omp task in_reduction(&& : argc)
154 #pragma omp task in_reduction(^ : T) // expected-error {{'T' does not refer to a value}}
156 #pragma omp taskgroup task_reduction(+:c)
157 #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 list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}} expected-error 2 {{in_reduction variable must appear in a task_reduction clause}}
159 #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 list item cannot be reduction}}
161 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
163 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
165 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
167 #pragma omp task in_reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
169 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} expected-error {{in_reduction variable must appear in a task_reduction clause}}
171 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
173 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
175 #pragma omp taskgroup task_reduction(+:k)
176 #pragma omp task in_reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
178 #pragma omp task in_reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
180 #pragma omp parallel private(k)
181 #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}}
183 #pragma omp taskgroup task_reduction(+:p)
184 #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}}
186 #pragma omp task in_reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
188 #pragma omp parallel shared(i)
189 #pragma omp parallel reduction(min : i)
190 #pragma omp task in_reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
192 #pragma omp taskgroup task_reduction(+:fl)
193 #pragma omp task in_reduction(+ : fl)
196 #pragma omp for reduction(- : fl)
197 for (int i = 0; i < 10; ++i)
198 #pragma omp taskgroup task_reduction(+:fl)
199 #pragma omp task in_reduction(+ : fl)
207 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
213 int main(int argc, char **argv) {
214 const int d = 5; // expected-note 2 {{'d' defined here}}
215 const int da[5] = {0}; // expected-note {{'da' defined here}}
220 int &j = i; // expected-note {{'j' defined here}}
221 S3 &p = k; // expected-note 2 {{'p' defined here}}
222 const int &r = da[i]; // expected-note {{'r' defined here}}
225 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
227 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
229 #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 '('}}
231 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
233 #pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
235 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
237 #pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
239 #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'}}
241 #pragma omp taskgroup task_reduction(|:argc)
243 #pragma omp taskgroup task_reduction(+:argc) // expected-note {{previously marked as task_reduction with different reduction operation}}
245 #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}}
248 #pragma omp task in_reduction(| : argc)
251 #pragma omp task in_reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
253 #pragma omp task in_reduction(~ : argc) // expected-error {{expected unqualified-id}}
255 #pragma omp taskgroup task_reduction(&&:argc)
256 #pragma omp task in_reduction(&& : argc)
258 #pragma omp task in_reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
260 #pragma omp taskgroup task_reduction(+:c)
261 #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 list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}} expected-error {{in_reduction variable must appear in a task_reduction clause}}
263 #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 list item cannot be reduction}}
265 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
267 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
269 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
271 #pragma omp task in_reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
273 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
275 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
277 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
279 #pragma omp task in_reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{nvalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
281 #pragma omp taskgroup task_reduction(+:k)
282 #pragma omp task in_reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
284 #pragma omp task in_reduction(+ : o) // expected-error {{no viable overloaded '='}}
286 #pragma omp parallel private(k)
287 #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}}
289 #pragma omp taskgroup task_reduction(+:p)
290 #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}}
292 #pragma omp task in_reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
294 #pragma omp parallel shared(i)
295 #pragma omp parallel reduction(min : i)
296 #pragma omp task in_reduction(max : j) // expected-error {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
299 #pragma omp for private(fl)
300 for (int i = 0; i < 10; ++i)
301 #pragma omp taskgroup task_reduction(+:fl)
302 #pragma omp task in_reduction(+ : fl)
304 #pragma omp taskgroup task_reduction(+:fl)
305 #pragma omp task in_reduction(+ : fl)
308 #pragma omp taskgroup task_reduction(+:m)
309 #pragma omp task in_reduction(+ : m) // OK
312 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}}