blob: fd358b2106bafa16a9dbab3b1bf45caa7bf1fcad [file] [log] [blame]
Alexey Bataev84d0b3e2014-07-08 08:12:03 +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 Bataev24b04aa2015-01-16 07:11:33 +000019 static float S2s;
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000020 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 Bataev84d0b3e2014-07-08 08:12:03 +000026 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000027 S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +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 Bataev84d0b3e2014-07-08 08:12:03 +000037 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000038 S4(); // expected-note 3 {{implicitly declared private here}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000039 S4(const S4 &s4);
40
41public:
42 S4(int v) : a(v) {}
43};
Alexey Bataev38e89532015-04-16 04:54:05 +000044class S5 {
Alexey Bataev84d0b3e2014-07-08 08:12:03 +000045 int a;
Alexey Bataev38e89532015-04-16 04:54:05 +000046 S5() : a(0) {} // expected-note {{implicitly declared private here}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +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 Bataev84d0b3e2014-07-08 08:12:03 +000068 int i;
69 int &j = i; // expected-note {{'j' defined here}}
70#pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
71 {
72 foo();
73 }
74#pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75 {
76 foo();
77 }
78#pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
79 {
80 foo();
81 }
82#pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83 {
84 foo();
85 }
86#pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87 {
88 foo();
89 }
90#pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
91 {
92 foo();
93 }
94#pragma omp parallel sections lastprivate(argc)
95 {
96 foo();
97 }
98#pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
99 {
100 foo();
101 }
102#pragma omp parallel sections lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
103 {
104 foo();
105 }
106#pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
107 {
108 foo();
109 }
Alexey Bataev38e89532015-04-16 04:54:05 +0000110#pragma omp parallel sections lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000111 {
112 foo();
113 }
114#pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
115 {
116 foo();
117 }
118#pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}
119 {
120 foo();
121 }
122#pragma omp parallel
123 {
124 int v = 0;
125 int i;
126#pragma omp parallel sections lastprivate(i)
127 {
128 foo();
129 }
130 v += i;
131 }
132#pragma omp parallel shared(i)
133#pragma omp parallel private(i)
134#pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
135 {
136 foo();
137 }
138#pragma omp parallel sections lastprivate(i)
139 {
140 foo();
141 }
142 return 0;
143}
144
145int main(int argc, char **argv) {
146 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
147 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
Alexey Bataev38e89532015-04-16 04:54:05 +0000148 S4 e(4);
149 S5 g(5);
150 S3 m;
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000151 S6 n(2);
152 int i;
153 int &j = i; // expected-note {{'j' defined here}}
154#pragma omp parallel sections lastprivate // expected-error {{expected '(' after 'lastprivate'}}
155 {
156 foo();
157 }
158#pragma omp parallel sections lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
159 {
160 foo();
161 }
162#pragma omp parallel sections lastprivate() // expected-error {{expected expression}}
163 {
164 foo();
165 }
166#pragma omp parallel sections lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
167 {
168 foo();
169 }
170#pragma omp parallel sections lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
171 {
172 foo();
173 }
174#pragma omp parallel sections lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
175 {
176 foo();
177 }
178#pragma omp parallel sections lastprivate(argc)
179 {
180 foo();
181 }
182#pragma omp parallel sections lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
183 {
184 foo();
185 }
186#pragma omp parallel sections lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
187 {
188 foo();
189 }
190#pragma omp parallel sections lastprivate(argv[1]) // expected-error {{expected variable name}}
191 {
192 foo();
193 }
194#pragma omp parallel sections lastprivate(2 * 2) // expected-error {{expected variable name}}
195 {
196 foo();
197 }
198#pragma omp parallel sections lastprivate(ba)
199 {
200 foo();
201 }
202#pragma omp parallel sections lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
203 {
204 foo();
205 }
206#pragma omp parallel sections lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
207 {
208 foo();
209 }
210 int xa;
211#pragma omp parallel sections lastprivate(xa) // OK
212 {
213 foo();
214 }
Alexey Bataev24b04aa2015-01-16 07:11:33 +0000215#pragma omp parallel sections lastprivate(S2::S2s)
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000216 {
217 foo();
218 }
219#pragma omp parallel sections lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
220 {
221 foo();
222 }
223#pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}}
224 {
225 foo();
226 }
Alexey Bataev38e89532015-04-16 04:54:05 +0000227#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'}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000228 {
229 foo();
230 }
Alexey Bataev38e89532015-04-16 04:54:05 +0000231#pragma omp parallel sections lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000232 {
233 foo();
234 }
235#pragma omp parallel sections lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
236 {
237 foo();
238 }
239#pragma omp parallel sections private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
240 {
241 foo();
242 }
243#pragma omp parallel sections lastprivate(i)
244 {
245 foo();
246 }
247#pragma omp parallel private(xa)
248#pragma omp parallel sections lastprivate(xa)
249 {
250 foo();
251 }
252#pragma omp parallel reduction(+ : xa)
253#pragma omp parallel sections lastprivate(xa)
254 {
255 foo();
256 }
257#pragma omp parallel sections lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
258 {
259 foo();
260 }
Alexey Bataev38e89532015-04-16 04:54:05 +0000261#pragma omp parallel sections firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000262 {
263 foo();
264 }
265#pragma omp parallel sections lastprivate(n) firstprivate(n) // OK
266 {
267 foo();
268 }
269 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
270}