Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / masked_taskloop_simd_firstprivate_messages.cpp
blobb49062988eaaab400d0f20558d7d1f5729498399
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 typedef void **omp_allocator_handle_t;
6 extern const omp_allocator_handle_t omp_null_allocator;
7 extern const omp_allocator_handle_t omp_default_mem_alloc;
8 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
9 extern const omp_allocator_handle_t omp_const_mem_alloc;
10 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
11 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
12 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
13 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
14 extern const omp_allocator_handle_t omp_thread_mem_alloc;
16 void foo() {
19 bool foobool(int argc) {
20 return argc;
23 void xxx(int argc) {
24 int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
25 #pragma omp masked taskloop simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
26 for (int i = 0; i < 10; ++i)
30 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
31 extern S1 a;
32 class S2 {
33 mutable int a;
35 public:
36 S2() : a(0) {}
37 S2(const S2 &s2) : a(s2.a) {}
38 static float S2s;
39 static const float S2sc;
41 const float S2::S2sc = 0;
42 const S2 b;
43 const S2 ba[5];
44 class S3 {
45 int a;
46 S3 &operator=(const S3 &s3);
48 public:
49 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
50 S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
52 const S3 c;
53 const S3 ca[5];
54 extern const int f;
55 class S4 {
56 int a;
57 S4();
58 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
60 public:
61 S4(int v) : a(v) {}
63 class S5 {
64 int a;
65 S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
67 public:
68 S5() : a(0) {}
69 S5(int v) : a(v) {}
71 class S6 {
72 int a;
73 S6() : a(0) {}
75 public:
76 S6(const S6 &s6) : a(s6.a) {}
77 S6(int v) : a(v) {}
80 S3 h;
81 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
83 template <class I, class C>
84 int foomain(int argc, char **argv) {
85 I e(4);
86 C g(5);
87 int i, z;
88 int &j = i;
89 #pragma omp parallel
90 #pragma omp masked taskloop simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
91 for (int k = 0; k < argc; ++k)
92 ++k;
93 #pragma omp parallel
94 #pragma omp masked taskloop simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int k = 0; k < argc; ++k)
96 ++k;
97 #pragma omp parallel
98 #pragma omp masked taskloop simd firstprivate() // expected-error {{expected expression}}
99 for (int k = 0; k < argc; ++k)
100 ++k;
101 #pragma omp parallel
102 #pragma omp masked taskloop simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (int k = 0; k < argc; ++k)
104 ++k;
105 #pragma omp parallel
106 #pragma omp masked taskloop simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
107 for (int k = 0; k < argc; ++k)
108 ++k;
109 #pragma omp parallel
110 #pragma omp masked taskloop simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
111 for (int k = 0; k < argc; ++k)
112 ++k;
113 #pragma omp parallel
114 #pragma omp masked taskloop simd firstprivate(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 '('}}
115 for (int k = 0; k < argc; ++k)
116 ++k;
117 #pragma omp parallel
118 #pragma omp masked taskloop simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
119 for (int k = 0; k < argc; ++k)
120 ++k;
121 #pragma omp parallel
122 #pragma omp masked taskloop simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
123 for (int k = 0; k < argc; ++k)
124 ++k;
125 #pragma omp parallel
126 #pragma omp masked taskloop simd firstprivate(z, argv[1]) // expected-error {{expected variable name}}
127 for (int k = 0; k < argc; ++k)
128 ++k;
129 #pragma omp parallel
130 #pragma omp masked taskloop simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
131 for (int k = 0; k < argc; ++k)
132 ++k;
133 #pragma omp parallel
134 #pragma omp masked taskloop simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
135 for (int k = 0; k < argc; ++k)
136 ++k;
137 #pragma omp parallel
139 int v = 0;
140 int i;
141 #pragma omp masked taskloop simd allocate(omp_thread_mem_alloc: i) firstprivate(i) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'masked taskloop simd' directive}}
142 for (int k = 0; k < argc; ++k) {
143 i = k;
144 v += i;
147 #pragma omp parallel shared(i)
148 #pragma omp parallel private(i)
149 #pragma omp masked taskloop simd firstprivate(j)
150 for (int k = 0; k < argc; ++k)
151 ++k;
152 #pragma omp parallel
153 #pragma omp masked taskloop simd firstprivate(i)
154 for (int k = 0; k < argc; ++k)
155 ++k;
156 #pragma omp parallel
157 #pragma omp masked taskloop simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
158 for (i = 0; i < argc; ++i)
159 foo();
160 #pragma omp parallel private(i)
161 #pragma omp masked taskloop simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
162 for (i = 0; i < argc; ++i) // expected-error 2 {{loop iteration variable in the associated loop of 'omp masked taskloop simd' directive may not be firstprivate, predetermined as linear}}
163 foo();
164 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
165 #pragma omp masked taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}} expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
166 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp masked taskloop simd' directive may not be firstprivate, predetermined as linear}}
167 foo();
168 return 0;
171 void bar(S4 a[2]) {
172 #pragma omp parallel
173 #pragma omp masked taskloop simd firstprivate(a)
174 for (int i = 0; i < 2; ++i)
175 foo();
178 namespace A {
179 double x;
180 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
182 namespace B {
183 using A::x;
186 int main(int argc, char **argv) {
187 const int d = 5;
188 const int da[5] = {0};
189 S4 e(4);
190 S5 g(5);
191 S3 m;
192 S6 n(2);
193 int i, z;
194 int &j = i;
195 int tid = 0;
196 #pragma omp parallel
197 #pragma omp masked taskloop simd firstprivate filter(tid) // expected-error {{expected '(' after 'firstprivate'}}
198 for (i = 0; i < argc; ++i)
199 foo();
200 #pragma omp parallel
201 #pragma omp masked taskloop simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
202 for (i = 0; i < argc; ++i)
203 foo();
204 #pragma omp parallel
205 #pragma omp masked taskloop simd firstprivate() // expected-error {{expected expression}}
206 for (i = 0; i < argc; ++i)
207 foo();
208 #pragma omp parallel
209 #pragma omp masked taskloop simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
210 for (i = 0; i < argc; ++i)
211 foo();
212 #pragma omp parallel
213 #pragma omp masked taskloop simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
214 for (i = 0; i < argc; ++i)
215 foo();
216 #pragma omp parallel
217 #pragma omp masked taskloop simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
218 for (i = 0; i < argc; ++i)
219 foo();
220 #pragma omp parallel
221 #pragma omp masked taskloop simd firstprivate(argc, z)
222 for (i = 0; i < argc; ++i)
223 foo();
224 #pragma omp parallel
225 #pragma omp masked taskloop simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
226 for (i = 0; i < argc; ++i)
227 foo();
228 #pragma omp parallel
229 #pragma omp masked taskloop simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
230 for (i = 0; i < argc; ++i)
231 foo();
232 #pragma omp parallel
233 #pragma omp masked taskloop simd firstprivate(argv[1]) // expected-error {{expected variable name}}
234 for (i = 0; i < argc; ++i)
235 foo();
236 #pragma omp parallel
237 #pragma omp masked taskloop simd firstprivate(2 * 2) // expected-error {{expected variable name}}
238 for (i = 0; i < argc; ++i)
239 foo();
240 #pragma omp parallel
241 #pragma omp masked taskloop simd firstprivate(ba) // OK
242 for (i = 0; i < argc; ++i)
243 foo();
244 #pragma omp parallel
245 #pragma omp masked taskloop simd firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
246 for (i = 0; i < argc; ++i)
247 foo();
248 #pragma omp parallel
249 #pragma omp masked taskloop simd firstprivate(da) // OK
250 for (i = 0; i < argc; ++i)
251 foo();
252 int xa;
253 #pragma omp parallel
254 #pragma omp masked taskloop simd firstprivate(xa) // OK
255 for (i = 0; i < argc; ++i)
256 foo();
257 #pragma omp parallel
258 #pragma omp masked taskloop simd firstprivate(S2::S2s) // OK
259 for (i = 0; i < argc; ++i)
260 foo();
261 #pragma omp parallel
262 #pragma omp masked taskloop simd firstprivate(S2::S2sc) // OK
263 for (i = 0; i < argc; ++i)
264 foo();
265 #pragma omp parallel
266 #pragma omp masked taskloop simd safelen(5)
267 for (i = 0; i < argc; ++i)
268 foo();
269 #pragma omp parallel
270 #pragma omp masked taskloop simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
271 for (i = 0; i < argc; ++i)
272 foo();
273 #pragma omp parallel
274 #pragma omp masked taskloop simd firstprivate(m) // OK
275 for (i = 0; i < argc; ++i)
276 foo();
277 #pragma omp parallel
278 #pragma omp masked taskloop simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
279 for (i = 0; i < argc; ++i)
280 foo();
281 #pragma omp parallel
282 #pragma omp masked taskloop simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
283 for (i = 0; i < argc; ++i)
284 foo();
285 #pragma omp parallel
286 #pragma omp masked taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
287 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp masked taskloop simd' directive may not be firstprivate, predetermined as linear}}
288 foo();
289 #pragma omp parallel shared(xa)
290 #pragma omp masked taskloop simd firstprivate(xa) // OK: may be firstprivate
291 for (i = 0; i < argc; ++i)
292 foo();
293 #pragma omp parallel
294 #pragma omp masked taskloop simd firstprivate(j)
295 for (i = 0; i < argc; ++i)
296 foo();
297 #pragma omp parallel
298 #pragma omp masked taskloop simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
299 for (i = 0; i < argc; ++i)
300 foo();
301 #pragma omp parallel
302 #pragma omp masked taskloop simd lastprivate(n) firstprivate(n) // OK
303 for (i = 0; i < argc; ++i)
304 foo();
305 #pragma omp parallel
307 int v = 0;
308 int i;
309 #pragma omp masked taskloop simd firstprivate(i)
310 for (int k = 0; k < argc; ++k) {
311 i = k;
312 v += i;
315 #pragma omp parallel private(i)
316 #pragma omp masked taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
317 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp masked taskloop simd' directive may not be firstprivate, predetermined as linear}}
318 foo();
319 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
320 #pragma omp masked taskloop simd firstprivate(i) // expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
321 for (i = 0; i < argc; ++i)
322 foo();
323 #pragma omp masked taskloop simd firstprivate(i) //expected-note {{defined as firstprivate}}
324 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp masked taskloop simd' directive may not be firstprivate, predetermined as linear}}
325 foo();
326 #pragma omp parallel
327 #pragma omp masked taskloop simd firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
328 for (i = 0; i < argc; ++i)
329 foo();
330 static int si;
331 #pragma omp masked taskloop simd firstprivate(si) // OK
332 for (i = 0; i < argc; ++i)
333 si = i + 1;
335 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}