• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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}}
9 
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;
20 
foo()21 void foo() {
22 }
23 
foobool(int argc)24 bool foobool(int argc) {
25   return argc;
26 }
27 
foobar(int & ref)28 void foobar(int &ref) {
29 #pragma omp taskgroup task_reduction(+:ref)
30 #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}}
31   foo();
32 }
33 
foobar1(int & ref)34 void foobar1(int &ref) {
35 #pragma omp taskgroup task_reduction(+:ref)
36 #pragma omp task in_reduction(-:ref)
37   foo();
38 }
39 
40 #pragma omp declare reduction (red:int:omp_out += omp_in)
41 
foobar2(int & ref)42 void foobar2(int &ref) {
43 #pragma omp taskgroup task_reduction(+:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
44 #pragma omp task in_reduction(red:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
45   foo();
46 }
47 
foobar3(int & ref)48 void foobar3(int &ref) {
49 #pragma omp taskgroup task_reduction(red:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
50 #pragma omp task in_reduction(min:ref)  // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
51   foo();
52 }
53 
foobar4(int & ref)54 void foobar4(int &ref) {
55 #pragma omp task in_reduction(min:ref)
56   foo();
57 }
58 
59 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
60 extern S1 a;
61 class S2 {
62   mutable int a;
operator +(const S2 & arg)63   S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
64 
65 public:
S2()66   S2() : a(0) {}
S2(S2 & s2)67   S2(S2 &s2) : a(s2.a) {}
68   static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
69   static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
70 };
71 const float S2::S2sc = 0;
72 S2 b;                     // expected-note 3 {{'b' defined here}}
73 const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
74 class S3 {
75   int a;
76 
77 public:
78   int b;
S3()79   S3() : a(0) {}
S3(const S3 & s3)80   S3(const S3 &s3) : a(s3.a) {}
operator +(const S3 & arg1)81   S3 operator+(const S3 &arg1) { return arg1; }
82 };
operator +(const S3 & arg1,const S3 & arg2)83 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
84 S3 c;               // expected-note 3 {{'c' defined here}}
85 const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
86 extern const int f; // expected-note 4 {{'f' declared here}}
87 class S4 {
88   int a;
89   S4(); // expected-note {{implicitly declared private here}}
90   S4(const S4 &s4);
operator +(const S4 & arg)91   S4 &operator+(const S4 &arg) { return (*this); }
92 
93 public:
S4(int v)94   S4(int v) : a(v) {}
95 };
operator &=(S4 & arg1,S4 & arg2)96 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
97 class S5 {
98   int a;
S5()99   S5() : a(0) {} // expected-note {{implicitly declared private here}}
S5(const S5 & s5)100   S5(const S5 &s5) : a(s5.a) {}
101   S5 &operator+(const S5 &arg);
102 
103 public:
S5(int v)104   S5(int v) : a(v) {}
105 };
106 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}}
107 #if __cplusplus >= 201103L // C++11 or later
108 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
109 #endif
110   int a;
111 
112 public:
S6()113   S6() : a(6) {}
operator int()114   operator int() { return 6; }
115 } o;
116 
117 S3 h, k;
118 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
119 
120 template <class T>       // expected-note {{declared here}}
tmain(T argc)121 T tmain(T argc) {
122   const T d = T();       // expected-note 4 {{'d' defined here}}
123   const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
124   T qa[5] = {T()};
125   T i;
126   T &j = i;                    // expected-note 2 {{'j' defined here}}
127   S3 &p = k;                   // expected-note 2 {{'p' defined here}}
128   const T &r = da[(int)i];     // expected-note 2 {{'r' defined here}}
129   T &q = qa[(int)i];
130   T fl;
131 #pragma omp taskgroup task_reduction(+:argc)
132 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
133   foo();
134 #pragma omp taskgroup task_reduction(+:argc)
135 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
136   foo();
137 #pragma omp taskgroup task_reduction(+:argc)
138 #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 '('}}
139   foo();
140 #pragma omp taskgroup task_reduction(+:argc)
141 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
142   foo();
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}}
145   foo();
146 #pragma omp taskgroup task_reduction(+:argc)
147 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
148   foo();
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}}
151   foo();
152 #pragma omp taskgroup task_reduction(&:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
153 #pragma omp task in_reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
154   foo();
155 #pragma omp taskgroup task_reduction(|:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
156 #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')}}
157   foo();
158 #pragma omp task in_reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
159   foo();
160 #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'}}
161   foo();
162 #pragma omp taskgroup task_reduction(&&:argc)
163 #pragma omp task in_reduction(&& : argc)
164   foo();
165 #pragma omp task in_reduction(^ : T) // expected-error {{'T' does not refer to a value}}
166   foo();
167 #pragma omp taskgroup task_reduction(+:c)
168 #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'}}
169   foo();
170 #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}}
171   foo();
172 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
173   foo();
174 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified variable cannot be in_reduction}}
175   foo();
176 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified variable cannot be in_reduction}}
177   foo();
178 #pragma omp task in_reduction(- : da) // expected-error {{const-qualified variable cannot be in_reduction}} expected-error {{const-qualified variable cannot be in_reduction}}
179   foo();
180 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
181   foo();
182 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
183   foo();
184 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be in_reduction}}
185   foo();
186 #pragma omp taskgroup task_reduction(+:k)
187 #pragma omp task in_reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
188   foo();
189 #pragma omp task in_reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
190   foo();
191 #pragma omp parallel private(k)
192 #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}}
193   foo();
194 #pragma omp taskgroup task_reduction(+:p)
195 #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}}
196   foo();
197 #pragma omp task in_reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be in_reduction}}
198   foo();
199 #pragma omp parallel shared(i)
200 #pragma omp parallel reduction(min : i)
201 #pragma omp task in_reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
202   foo();
203 #pragma omp taskgroup task_reduction(+:fl)
204 #pragma omp task in_reduction(+ : fl)
205     foo();
206 #pragma omp parallel
207 #pragma omp for reduction(- : fl)
208   for (int i = 0; i < 10; ++i)
209 #pragma omp taskgroup task_reduction(+:fl)
210 #pragma omp task in_reduction(+ : fl)
211     foo();
212 
213   return T();
214 }
215 
216 namespace A {
217 double x;
218 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
219 }
220 namespace B {
221 using A::x;
222 }
223 
main(int argc,char ** argv)224 int main(int argc, char **argv) {
225   const int d = 5;       // expected-note 2 {{'d' defined here}}
226   const int da[5] = {0}; // expected-note {{'da' defined here}}
227   int qa[5] = {0};
228   S4 e(4);
229   S5 g(5);
230   int i;
231   int &j = i;                  // expected-note {{'j' defined here}}
232   S3 &p = k;                   // expected-note 2 {{'p' defined here}}
233   const int &r = da[i];        // expected-note {{'r' defined here}}
234   int &q = qa[i];
235   float fl;
236 #pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
237   foo();
238 #pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
239   foo();
240 #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 '('}}
241   foo();
242 #pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
243   foo();
244 #pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
245   foo();
246 #pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
247   foo();
248 #pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
249   foo();
250 #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'}}
251   foo();
252 #pragma omp taskgroup task_reduction(|:argc)
253 {
254 #pragma omp taskgroup task_reduction(+:argc) // expected-note {{previously marked as task_reduction with different reduction operation}}
255 {
256 #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}}
257   foo();
258 }
259 #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 '('}}
260   foo();
261 }
262 #pragma omp task in_reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
263   foo();
264 #pragma omp task in_reduction(~ : argc) // expected-error {{expected unqualified-id}}
265   foo();
266 #pragma omp taskgroup task_reduction(&&:argc)
267 #pragma omp task in_reduction(&& : argc)
268   foo();
269 #pragma omp task in_reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
270   foo();
271 #pragma omp taskgroup task_reduction(+:c)
272 #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'}}
273   foo();
274 #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}}
275   foo();
276 #pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
277   foo();
278 #pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified variable cannot be in_reduction}}
279   foo();
280 #pragma omp task in_reduction(* : ca) // expected-error {{const-qualified variable cannot be in_reduction}}
281   foo();
282 #pragma omp task in_reduction(- : da) // expected-error {{const-qualified variable cannot be in_reduction}}
283   foo();
284 #pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
285   foo();
286 #pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
287   foo();
288 #pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be in_reduction}}
289   foo();
290 #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')}}
291   foo();
292 #pragma omp taskgroup task_reduction(+:k)
293 #pragma omp task in_reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
294   foo();
295 #pragma omp task in_reduction(+ : o) // expected-error {{no viable overloaded '='}}
296   foo();
297 #pragma omp parallel private(k)
298 #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}}
299   foo();
300 #pragma omp taskgroup task_reduction(+:p)
301 #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}}
302   foo();
303 #pragma omp task in_reduction(+ : r) // expected-error {{const-qualified variable cannot be in_reduction}}
304   foo();
305 #pragma omp parallel shared(i)
306 #pragma omp parallel reduction(min : i)
307 #pragma omp task in_reduction(max : j) // expected-error {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
308   foo();
309 #pragma omp parallel
310 #pragma omp for private(fl)
311   for (int i = 0; i < 10; ++i)
312 #pragma omp taskgroup task_reduction(+:fl)
313 #pragma omp task in_reduction(+ : fl)
314     foo();
315 #pragma omp taskgroup task_reduction(+:fl)
316 #pragma omp task in_reduction(+ : fl)
317     foo();
318   static int m;
319 #pragma omp taskgroup task_reduction(+:m)
320 #pragma omp task in_reduction(+ : m) // OK
321   m++;
322 
323   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}}
324 }
325