1 | // RUN: %clang_cc1 -verify -fopenmp %s |
2 | |
3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
4 | |
5 | typedef void **omp_allocator_handle_t; |
6 | extern const omp_allocator_handle_t omp_default_mem_alloc; |
7 | extern const omp_allocator_handle_t omp_large_cap_mem_alloc; |
8 | extern const omp_allocator_handle_t omp_const_mem_alloc; |
9 | extern const omp_allocator_handle_t omp_high_bw_mem_alloc; |
10 | extern const omp_allocator_handle_t omp_low_lat_mem_alloc; |
11 | extern const omp_allocator_handle_t omp_cgroup_mem_alloc; |
12 | extern const omp_allocator_handle_t omp_pteam_mem_alloc; |
13 | extern const omp_allocator_handle_t omp_thread_mem_alloc; |
14 | |
15 | void foo() { |
16 | } |
17 | |
18 | bool foobool(int argc) { |
19 | return argc; |
20 | } |
21 | |
22 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
23 | extern S1 a; |
24 | class S2 { |
25 | mutable int a; |
26 | |
27 | public: |
28 | S2() : a(0) {} |
29 | S2(S2 &s2) : a(s2.a) {} |
30 | const S2 &operator =(const S2&) const; |
31 | S2 &operator =(const S2&); |
32 | static float S2s; // expected-note {{static data member is predetermined as shared}} |
33 | static const float S2sc; // expected-note {{'S2sc' declared here}} |
34 | }; |
35 | const float S2::S2sc = 0; |
36 | const S2 b; |
37 | const S2 ba[5]; |
38 | class S3 { |
39 | int a; |
40 | S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}} |
41 | |
42 | public: |
43 | S3() : a(0) {} |
44 | S3(S3 &s3) : a(s3.a) {} |
45 | }; |
46 | const S3 c; // expected-note {{'c' defined here}} |
47 | const S3 ca[5]; // expected-note {{'ca' defined here}} |
48 | extern const int f; // expected-note {{'f' declared here}} |
49 | class S4 { |
50 | int a; |
51 | S4(); // expected-note 3 {{implicitly declared private here}} |
52 | S4(const S4 &s4); |
53 | |
54 | public: |
55 | S4(int v) : a(v) {} |
56 | }; |
57 | class S5 { |
58 | int a; |
59 | S5() : a(0) {} // expected-note {{implicitly declared private here}} |
60 | |
61 | public: |
62 | S5(const S5 &s5) : a(s5.a) {} |
63 | S5(int v) : a(v) {} |
64 | }; |
65 | class S6 { |
66 | int a; |
67 | S6() : a(0) {} |
68 | |
69 | public: |
70 | S6(const S6 &s6) : a(s6.a) {} |
71 | S6(int v) : a(v) {} |
72 | }; |
73 | |
74 | S3 h; |
75 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
76 | |
77 | template <class I, class C> |
78 | int foomain(int argc, char **argv) { |
79 | I e(4); |
80 | I g(5); |
81 | int i; |
82 | int &j = i; |
83 | #pragma omp parallel |
84 | #pragma omp taskloop simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
85 | for (int k = 0; k < argc; ++k) |
86 | ++k; |
87 | #pragma omp parallel |
88 | #pragma omp taskloop simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
89 | for (int k = 0; k < argc; ++k) |
90 | ++k; |
91 | #pragma omp parallel |
92 | #pragma omp taskloop simd lastprivate() // expected-error {{expected expression}} |
93 | for (int k = 0; k < argc; ++k) |
94 | ++k; |
95 | #pragma omp parallel |
96 | #pragma omp taskloop simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
97 | for (int k = 0; k < argc; ++k) |
98 | ++k; |
99 | #pragma omp parallel |
100 | #pragma omp taskloop simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
101 | for (int k = 0; k < argc; ++k) |
102 | ++k; |
103 | #pragma omp parallel |
104 | #pragma omp taskloop simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
105 | for (int k = 0; k < argc; ++k) |
106 | ++k; |
107 | #pragma omp parallel |
108 | #pragma omp taskloop simd lastprivate(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 '('}} |
109 | for (int k = 0; k < argc; ++k) |
110 | ++k; |
111 | #pragma omp parallel |
112 | #pragma omp taskloop simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
113 | for (int k = 0; k < argc; ++k) |
114 | ++k; |
115 | #pragma omp parallel |
116 | #pragma omp taskloop simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} |
117 | for (int k = 0; k < argc; ++k) |
118 | ++k; |
119 | #pragma omp parallel |
120 | #pragma omp taskloop simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
121 | for (int k = 0; k < argc; ++k) |
122 | ++k; |
123 | #pragma omp parallel |
124 | #pragma omp taskloop simd lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} |
125 | for (int k = 0; k < argc; ++k) |
126 | ++k; |
127 | #pragma omp parallel |
128 | #pragma omp taskloop simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
129 | for (int k = 0; k < argc; ++k) |
130 | ++k; |
131 | #pragma omp parallel |
132 | { |
133 | int v = 0; |
134 | int i; |
135 | #pragma omp taskloop simd lastprivate(i) allocate(omp_thread_mem_alloc: i) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'taskloop simd' directive}} |
136 | for (int k = 0; k < argc; ++k) { |
137 | i = k; |
138 | v += i; |
139 | } |
140 | } |
141 | #pragma omp parallel shared(i) |
142 | #pragma omp parallel private(i) |
143 | #pragma omp taskloop simd lastprivate(j) |
144 | for (int k = 0; k < argc; ++k) |
145 | ++k; |
146 | #pragma omp parallel |
147 | #pragma omp taskloop simd lastprivate(i) |
148 | for (int k = 0; k < argc; ++k) |
149 | ++k; |
150 | return 0; |
151 | } |
152 | |
153 | void bar(S4 a[2]) { |
154 | #pragma omp parallel |
155 | #pragma omp taskloop simd lastprivate(a) |
156 | for (int i = 0; i < 2; ++i) |
157 | foo(); |
158 | } |
159 | |
160 | namespace A { |
161 | double x; |
162 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
163 | } |
164 | namespace B { |
165 | using A::x; |
166 | } |
167 | |
168 | int main(int argc, char **argv) { |
169 | const int d = 5; // expected-note {{'d' defined here}} |
170 | const int da[5] = {0}; // expected-note {{'da' defined here}} |
171 | S4 e(4); |
172 | S5 g(5); |
173 | S3 m; |
174 | S6 n(2); |
175 | int i; |
176 | int &j = i; |
177 | #pragma omp parallel |
178 | #pragma omp taskloop simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
179 | for (i = 0; i < argc; ++i) |
180 | foo(); |
181 | #pragma omp parallel |
182 | #pragma omp taskloop simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
183 | for (i = 0; i < argc; ++i) |
184 | foo(); |
185 | #pragma omp parallel |
186 | #pragma omp taskloop simd lastprivate() // expected-error {{expected expression}} |
187 | for (i = 0; i < argc; ++i) |
188 | foo(); |
189 | #pragma omp parallel |
190 | #pragma omp taskloop simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
191 | for (i = 0; i < argc; ++i) |
192 | foo(); |
193 | #pragma omp parallel |
194 | #pragma omp taskloop simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
195 | for (i = 0; i < argc; ++i) |
196 | foo(); |
197 | #pragma omp parallel |
198 | #pragma omp taskloop simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
199 | for (i = 0; i < argc; ++i) |
200 | foo(); |
201 | #pragma omp parallel |
202 | #pragma omp taskloop simd lastprivate(argc) |
203 | for (i = 0; i < argc; ++i) |
204 | foo(); |
205 | #pragma omp parallel |
206 | #pragma omp taskloop simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
207 | for (i = 0; i < argc; ++i) |
208 | foo(); |
209 | #pragma omp parallel |
210 | #pragma omp taskloop simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be lastprivate}} expected-error 2 {{const-qualified variable cannot be lastprivate}} |
211 | for (i = 0; i < argc; ++i) |
212 | foo(); |
213 | #pragma omp parallel |
214 | #pragma omp taskloop simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
215 | for (i = 0; i < argc; ++i) |
216 | foo(); |
217 | #pragma omp parallel |
218 | #pragma omp taskloop simd lastprivate(2 * 2) // expected-error {{expected variable name}} |
219 | for (i = 0; i < argc; ++i) |
220 | foo(); |
221 | #pragma omp parallel |
222 | #pragma omp taskloop simd lastprivate(ba) |
223 | for (i = 0; i < argc; ++i) |
224 | foo(); |
225 | #pragma omp parallel |
226 | #pragma omp taskloop simd lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}} |
227 | for (i = 0; i < argc; ++i) |
228 | foo(); |
229 | #pragma omp parallel |
230 | #pragma omp taskloop simd lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}} |
231 | for (i = 0; i < argc; ++i) |
232 | foo(); |
233 | int xa; |
234 | #pragma omp parallel |
235 | #pragma omp taskloop simd lastprivate(xa) // OK |
236 | for (i = 0; i < argc; ++i) |
237 | foo(); |
238 | #pragma omp parallel |
239 | #pragma omp taskloop simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} |
240 | for (i = 0; i < argc; ++i) |
241 | foo(); |
242 | #pragma omp parallel |
243 | #pragma omp taskloop simd lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}} |
244 | for (i = 0; i < argc; ++i) |
245 | foo(); |
246 | #pragma omp parallel |
247 | #pragma omp taskloop simd safelen(5) |
248 | for (i = 0; i < argc; ++i) |
249 | foo(); |
250 | #pragma omp parallel |
251 | #pragma omp taskloop simd lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
252 | for (i = 0; i < argc; ++i) |
253 | foo(); |
254 | #pragma omp parallel |
255 | #pragma omp taskloop simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} |
256 | for (i = 0; i < argc; ++i) |
257 | foo(); |
258 | #pragma omp parallel |
259 | #pragma omp taskloop simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
260 | for (i = 0; i < argc; ++i) |
261 | foo(); |
262 | #pragma omp parallel |
263 | #pragma omp taskloop simd lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
264 | for (i = 0; i < argc; ++i) |
265 | foo(); |
266 | #pragma omp parallel |
267 | #pragma omp taskloop simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} |
268 | for (i = 0; i < argc; ++i) |
269 | foo(); |
270 | #pragma omp parallel |
271 | #pragma omp taskloop simd lastprivate(i) // expected-note {{defined as lastprivate}} |
272 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be lastprivate, predetermined as linear}} |
273 | foo(); |
274 | #pragma omp parallel private(xa) |
275 | #pragma omp taskloop simd lastprivate(xa) |
276 | for (i = 0; i < argc; ++i) |
277 | foo(); |
278 | #pragma omp parallel reduction(+ : xa) |
279 | #pragma omp taskloop simd lastprivate(xa) |
280 | for (i = 0; i < argc; ++i) |
281 | foo(); |
282 | #pragma omp parallel |
283 | #pragma omp taskloop simd lastprivate(j) |
284 | for (i = 0; i < argc; ++i) |
285 | foo(); |
286 | #pragma omp parallel |
287 | #pragma omp taskloop simd firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} |
288 | for (i = 0; i < argc; ++i) |
289 | foo(); |
290 | #pragma omp parallel |
291 | #pragma omp taskloop simd lastprivate(n) firstprivate(n) // OK |
292 | for (i = 0; i < argc; ++i) |
293 | foo(); |
294 | static int si; |
295 | #pragma omp taskloop simd lastprivate(si) // OK |
296 | for (i = 0; i < argc; ++i) |
297 | si = i + 1; |
298 | return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} |
299 | } |
300 | |