blob: 13640f610773af04de1e8f8049cbb1205a744165 [file] [log] [blame]
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00001// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11extern S1 a;
12class S2 {
13 mutable int a;
14
15public:
16 S2() : a(0) {}
17 S2(S2 &s2) : a(s2.a) {}
Alexey Bataev38e89532015-04-16 04:54:05 +000018 const S2 &operator=(const S2 &) const;
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000019 static float S2s; // expected-note {{static data member is predetermined as shared}}
20 static const float S2sc;
21};
22const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
23const S2 b;
24const S2 ba[5];
Alexey Bataev38e89532015-04-16 04:54:05 +000025class S3 {
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000026 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000027 S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000028
29public:
30 S3() : a(0) {}
31 S3(S3 &s3) : a(s3.a) {}
32};
33const S3 c; // expected-note {{global variable is predetermined as shared}}
34const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
35extern const int f; // expected-note {{global variable is predetermined as shared}}
Alexey Bataev38e89532015-04-16 04:54:05 +000036class S4 {
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000037 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000038 S4(); // expected-note 3 {{implicitly declared private here}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000039 S4(const S4 &s4);
40
41public:
42 S4(int v) : a(v) {}
43};
Alexey Bataev38e89532015-04-16 04:54:05 +000044class S5 {
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000045 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000046 S5() : a(0) {} // expected-note {{implicitly declared private here}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000047
48public:
49 S5(const S5 &s5) : a(s5.a) {}
50 S5(int v) : a(v) {}
51};
52class S6 {
53 int a;
54 S6() : a(0) {}
55
56public:
57 S6(const S6 &s6) : a(s6.a) {}
58 S6(int v) : a(v) {}
59};
60
61S3 h;
62#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
63
64template <class I, class C>
65int foomain(int argc, char **argv) {
Alexey Bataev38e89532015-04-16 04:54:05 +000066 I e(4);
67 I g(5);
Alexey Bataevd3f8dd22014-06-25 11:44:49 +000068 int i;
69 int &j = i; // expected-note {{'j' defined here}}
70#pragma omp parallel
71#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
72 {
73 foo();
74 }
75#pragma omp parallel
76#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 {
78 foo();
79 }
80#pragma omp parallel
81#pragma omp sections lastprivate() // expected-error {{expected expression}}
82 {
83 foo();
84 }
85#pragma omp parallel
86#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
87 {
88 foo();
89 }
90#pragma omp parallel
91#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
92 {
93 foo();
94 }
95#pragma omp parallel
96#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
97 {
98 foo();
99 }
100#pragma omp parallel
101#pragma omp sections lastprivate(argc)
102 {
103 foo();
104 }
105#pragma omp parallel
106#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
107 {
108 foo();
109 }
110#pragma omp parallel
111#pragma omp sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
112 {
113 foo();
114 }
115#pragma omp parallel
116#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}}
117 {
118 foo();
119 }
120#pragma omp parallel
Alexey Bataev38e89532015-04-16 04:54:05 +0000121#pragma omp sections lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000122 {
123 foo();
124 }
125#pragma omp parallel
126#pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
127 {
128 foo();
129 }
130#pragma omp parallel
131#pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}
132 {
133 foo();
134 }
135#pragma omp parallel
136 {
137 int v = 0;
138 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}}
139#pragma omp sections lastprivate(i) // expected-error {{lastprivate variable must be shared}}
140 {
141 foo();
142 }
143 v += i;
144 }
145#pragma omp parallel shared(i)
146#pragma omp parallel private(i)
147#pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
148 {
149 foo();
150 }
151#pragma omp parallel
152#pragma omp sections lastprivate(i)
153 {
154 foo();
155 }
156 return 0;
157}
158
159int main(int argc, char **argv) {
160 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
161 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
Alexey Bataev38e89532015-04-16 04:54:05 +0000162 S4 e(4);
163 S5 g(5);
164 S3 m;
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000165 S6 n(2);
166 int i;
167 int &j = i; // expected-note {{'j' defined here}}
168#pragma omp parallel
169#pragma omp sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
170 {
171 foo();
172 }
173#pragma omp parallel
174#pragma omp sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
175 {
176 foo();
177 }
178#pragma omp parallel
179#pragma omp sections lastprivate() // expected-error {{expected expression}}
180 {
181 foo();
182 }
183#pragma omp parallel
184#pragma omp sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
185 {
186 foo();
187 }
188#pragma omp parallel
189#pragma omp sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
190 {
191 foo();
192 }
193#pragma omp parallel
194#pragma omp sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
195 {
196 foo();
197 }
198#pragma omp parallel
199#pragma omp sections lastprivate(argc)
200 {
201 foo();
202 }
203#pragma omp parallel
204#pragma omp sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
205 {
206 foo();
207 }
208#pragma omp parallel
209#pragma omp sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
210 {
211 foo();
212 }
213#pragma omp parallel
214#pragma omp sections lastprivate(argv[1]) // expected-error {{expected variable name}}
215 {
216 foo();
217 }
218#pragma omp parallel
219#pragma omp sections lastprivate(2 * 2) // expected-error {{expected variable name}}
220 {
221 foo();
222 }
223#pragma omp parallel
224#pragma omp sections lastprivate(ba)
225 {
226 foo();
227 }
228#pragma omp parallel
229#pragma omp sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
230 {
231 foo();
232 }
233#pragma omp parallel
234#pragma omp sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
235 {
236 foo();
237 }
238 int xa;
239#pragma omp parallel
240#pragma omp sections lastprivate(xa) // OK
241 {
242 foo();
243 }
244#pragma omp parallel
245#pragma omp sections lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
246 {
247 foo();
248 }
249#pragma omp parallel
250#pragma omp sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
251 {
252 foo();
253 }
254#pragma omp parallel
255#pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}}
256 {
257 foo();
258 }
259#pragma omp parallel
Alexey Bataev38e89532015-04-16 04:54:05 +0000260#pragma omp sections lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000261 {
262 foo();
263 }
264#pragma omp parallel
Alexey Bataev38e89532015-04-16 04:54:05 +0000265#pragma omp sections lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000266 {
267 foo();
268 }
269#pragma omp parallel
270#pragma omp sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
271 {
272 foo();
273 }
274#pragma omp parallel
275#pragma omp sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
276 {
277 foo();
278 }
279#pragma omp parallel
280#pragma omp sections lastprivate(i)
281 {
282 foo();
283 }
284#pragma omp parallel private(xa) // expected-note {{defined as private}}
285#pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}}
286 {
287 foo();
288 }
289#pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}}
290#pragma omp sections lastprivate(xa) // expected-error {{lastprivate variable must be shared}}
291 {
292 foo();
293 }
294#pragma omp parallel
295#pragma omp sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
296 {
297 foo();
298 }
299#pragma omp parallel
Alexey Bataev38e89532015-04-16 04:54:05 +0000300#pragma omp sections firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000301 {
302 foo();
303 }
304#pragma omp parallel
305#pragma omp sections lastprivate(n) firstprivate(n) // OK
306 {
307 foo();
308 }
309 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
310}