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