1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp-simd %s
7 bool foobool(int argc) {
11 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
18 S2(const S2 &s2) : a(s2.a) {}
20 static const float S2sc;
22 const float S2::S2sc = 0;
27 S3 &operator=(const S3 &s3);
30 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
31 S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
39 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
46 S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
57 S6(const S6 &s6) : a(s6.a) {}
62 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
64 template <class I, class C>
65 int foomain(int argc, char **argv) {
71 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
72 for (int k = 0; k < argc; ++k)
75 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
76 for (int k = 0; k < argc; ++k)
79 #pragma omp for firstprivate() // expected-error {{expected expression}}
80 for (int k = 0; k < argc; ++k)
83 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (int k = 0; k < argc; ++k)
87 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
88 for (int k = 0; k < argc; ++k)
91 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
92 for (int k = 0; k < argc; ++k)
95 #pragma omp for firstprivate(argc)
96 for (int k = 0; k < argc; ++k)
99 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
100 for (int k = 0; k < argc; ++k)
103 #pragma omp for firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
104 for (int k = 0; k < argc; ++k)
107 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
108 for (int k = 0; k < argc; ++k)
111 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
112 for (int k = 0; k < argc; ++k)
115 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
116 for (int k = 0; k < argc; ++k)
121 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
122 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
123 for (int k = 0; k < argc; ++k) {
128 #pragma omp parallel shared(i)
129 #pragma omp parallel private(i)
130 #pragma omp for firstprivate(j)
131 for (int k = 0; k < argc; ++k)
134 #pragma omp for firstprivate(i)
135 for (int k = 0; k < argc; ++k)
138 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
139 for (i = 0; i < argc; ++i)
141 #pragma omp parallel private(i) // expected-note {{defined as private}}
142 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
143 for (i = 0; i < argc; ++i)
145 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
146 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
147 for (int k = 0; k < argc; ++k)
154 #pragma omp for firstprivate(a)
155 for (int i = 0; i < 2; ++i)
161 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
167 int main(int argc, char **argv) {
169 const int da[5] = {0};
177 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
178 for (i = 0; i < argc; ++i)
181 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
182 for (i = 0; i < argc; ++i)
185 #pragma omp for firstprivate() // expected-error {{expected expression}}
186 for (i = 0; i < argc; ++i)
189 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
190 for (i = 0; i < argc; ++i)
193 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
194 for (i = 0; i < argc; ++i)
197 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
198 for (i = 0; i < argc; ++i)
201 #pragma omp for firstprivate(argc)
202 for (i = 0; i < argc; ++i)
205 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
206 for (i = 0; i < argc; ++i)
209 #pragma omp for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
210 for (i = 0; i < argc; ++i)
213 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
214 for (i = 0; i < argc; ++i)
217 #pragma omp for firstprivate(2 * 2) // expected-error {{expected variable name}}
218 for (i = 0; i < argc; ++i)
221 #pragma omp for firstprivate(ba) // OK
222 for (i = 0; i < argc; ++i)
225 #pragma omp for firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
226 for (i = 0; i < argc; ++i)
229 #pragma omp for firstprivate(da) // OK
230 for (i = 0; i < argc; ++i)
234 #pragma omp for firstprivate(xa) // OK
235 for (i = 0; i < argc; ++i)
238 #pragma omp for firstprivate(S2::S2s) // OK
239 for (i = 0; i < argc; ++i)
242 #pragma omp for firstprivate(S2::S2sc) // OK
243 for (i = 0; i < argc; ++i)
246 #pragma omp for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp for'}}
247 for (i = 0; i < argc; ++i)
250 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
251 for (i = 0; i < argc; ++i)
254 #pragma omp for firstprivate(m) // OK
255 for (i = 0; i < argc; ++i)
258 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
259 for (i = 0; i < argc; ++i)
262 #pragma omp for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
263 for (i = 0; i < argc; ++i)
266 #pragma omp for firstprivate(i) // expected-note {{defined as firstprivate}}
267 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp for' directive may not be firstprivate, predetermined as private}}
269 #pragma omp parallel shared(xa)
270 #pragma omp for firstprivate(xa) // OK: may be firstprivate
271 for (i = 0; i < argc; ++i)
274 #pragma omp for firstprivate(j)
275 for (i = 0; i < argc; ++i)
278 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
279 for (i = 0; i < argc; ++i)
282 #pragma omp for lastprivate(n) firstprivate(n) // OK
283 for (i = 0; i < argc; ++i)
288 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
289 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
290 for (int k = 0; k < argc; ++k) {
295 #pragma omp parallel private(i) // expected-note {{defined as private}}
296 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
297 for (i = 0; i < argc; ++i)
299 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
300 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
301 for (i = 0; i < argc; ++i)
304 #pragma omp for firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
305 for (i = 0; i < argc; ++i)
308 #pragma omp for firstprivate(si) // OK
309 for (i = 0; i < argc; ++i)
312 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}