1 // RUN: %clang_cc1 -verify -fopenmp %s
6 bool foobool(int argc) {
10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
17 S2(const S2 &s2) : a(s2.a) {}
19 static const float S2sc;
21 const float S2::S2sc = 0;
26 S3 &operator=(const S3 &s3);
29 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
30 S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
38 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
45 S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
56 S6(const S6 &s6) : a(s6.a) {}
61 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
63 template <class I, class C>
64 int foomain(int argc, char **argv) {
70 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
71 for (int k = 0; k < argc; ++k)
74 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75 for (int k = 0; k < argc; ++k)
78 #pragma omp for firstprivate() // expected-error {{expected expression}}
79 for (int k = 0; k < argc; ++k)
82 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (int k = 0; k < argc; ++k)
86 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87 for (int k = 0; k < argc; ++k)
90 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
91 for (int k = 0; k < argc; ++k)
94 #pragma omp for firstprivate(argc)
95 for (int k = 0; k < argc; ++k)
98 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
99 for (int k = 0; k < argc; ++k)
102 #pragma omp for firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
103 for (int k = 0; k < argc; ++k)
106 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
107 for (int k = 0; k < argc; ++k)
110 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
111 for (int k = 0; k < argc; ++k)
114 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
115 for (int k = 0; k < argc; ++k)
120 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?}}
121 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
122 for (int k = 0; k < argc; ++k) {
127 #pragma omp parallel shared(i)
128 #pragma omp parallel private(i)
129 #pragma omp for firstprivate(j)
130 for (int k = 0; k < argc; ++k)
133 #pragma omp for firstprivate(i)
134 for (int k = 0; k < argc; ++k)
137 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
138 for (i = 0; i < argc; ++i)
140 #pragma omp parallel private(i) // expected-note {{defined as private}}
141 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
142 for (i = 0; i < argc; ++i)
144 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
145 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
146 for (int k = 0; k < argc; ++k)
153 #pragma omp for firstprivate(a)
154 for (int i = 0; i < 2; ++i)
160 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
166 int main(int argc, char **argv) {
168 const int da[5] = {0};
176 #pragma omp for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
177 for (i = 0; i < argc; ++i)
180 #pragma omp for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
181 for (i = 0; i < argc; ++i)
184 #pragma omp for firstprivate() // expected-error {{expected expression}}
185 for (i = 0; i < argc; ++i)
188 #pragma omp for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
189 for (i = 0; i < argc; ++i)
192 #pragma omp for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
193 for (i = 0; i < argc; ++i)
196 #pragma omp for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
197 for (i = 0; i < argc; ++i)
200 #pragma omp for firstprivate(argc)
201 for (i = 0; i < argc; ++i)
204 #pragma omp for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
205 for (i = 0; i < argc; ++i)
208 #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'}}
209 for (i = 0; i < argc; ++i)
212 #pragma omp for firstprivate(argv[1]) // expected-error {{expected variable name}}
213 for (i = 0; i < argc; ++i)
216 #pragma omp for firstprivate(2 * 2) // expected-error {{expected variable name}}
217 for (i = 0; i < argc; ++i)
220 #pragma omp for firstprivate(ba) // OK
221 for (i = 0; i < argc; ++i)
224 #pragma omp for firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
225 for (i = 0; i < argc; ++i)
228 #pragma omp for firstprivate(da) // OK
229 for (i = 0; i < argc; ++i)
233 #pragma omp for firstprivate(xa) // OK
234 for (i = 0; i < argc; ++i)
237 #pragma omp for firstprivate(S2::S2s) // OK
238 for (i = 0; i < argc; ++i)
241 #pragma omp for firstprivate(S2::S2sc) // OK
242 for (i = 0; i < argc; ++i)
245 #pragma omp for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp for'}}
246 for (i = 0; i < argc; ++i)
249 #pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
250 for (i = 0; i < argc; ++i)
253 #pragma omp for firstprivate(m) // OK
254 for (i = 0; i < argc; ++i)
257 #pragma omp for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
258 for (i = 0; i < argc; ++i)
261 #pragma omp for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
262 for (i = 0; i < argc; ++i)
265 #pragma omp for firstprivate(i) // expected-note {{defined as firstprivate}}
266 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}}
268 #pragma omp parallel shared(xa)
269 #pragma omp for firstprivate(xa) // OK: may be firstprivate
270 for (i = 0; i < argc; ++i)
273 #pragma omp for firstprivate(j)
274 for (i = 0; i < argc; ++i)
277 #pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
278 for (i = 0; i < argc; ++i)
281 #pragma omp for lastprivate(n) firstprivate(n) // OK
282 for (i = 0; i < argc; ++i)
287 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?}}
288 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
289 for (int k = 0; k < argc; ++k) {
294 #pragma omp parallel private(i) // expected-note {{defined as private}}
295 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
296 for (i = 0; i < argc; ++i)
298 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
299 #pragma omp for firstprivate(i) // expected-error {{firstprivate variable must be shared}}
300 for (i = 0; i < argc; ++i)
303 #pragma omp for firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
304 for (i = 0; i < argc; ++i)
307 #pragma omp for firstprivate(si) // OK
308 for (i = 0; i < argc; ++i)
311 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}