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