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