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