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