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(S2 &s2) : a(s2.a) {}
18 S2 &operator =(const S2&);
19 const S2 &operator =(const S2&) const;
20 static float S2s; // expected-note {{static data member is predetermined as shared}}
21 static const float S2sc;
23 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
28 S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
32 S3(S3 &s3) : a(s3.a) {}
34 const S3 c; // expected-note {{global variable is predetermined as shared}}
35 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
36 extern const int f; // expected-note {{global variable is predetermined as shared}}
39 S4(); // expected-note 3 {{implicitly declared private here}}
47 S5() : a(0) {} // expected-note {{implicitly declared private here}}
50 S5(const S5 &s5) : a(s5.a) {}
58 S6(const S6 &s6) : a(s6.a) {}
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
65 template <class I, class C>
66 int foomain(int argc, char **argv) {
70 int &j = i; // expected-note {{'j' defined here}}
72 #pragma omp for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
73 for (int k = 0; k < argc; ++k)
76 #pragma omp for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 for (int k = 0; k < argc; ++k)
80 #pragma omp for simd lastprivate() // expected-error {{expected expression}}
81 for (int k = 0; k < argc; ++k)
84 #pragma omp for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
85 for (int k = 0; k < argc; ++k)
88 #pragma omp for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
89 for (int k = 0; k < argc; ++k)
92 #pragma omp for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
93 for (int k = 0; k < argc; ++k)
96 #pragma omp for simd lastprivate(argc)
97 for (int k = 0; k < argc; ++k)
100 #pragma omp for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
101 for (int k = 0; k < argc; ++k)
104 #pragma omp for simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
105 for (int k = 0; k < argc; ++k)
108 #pragma omp for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
109 for (int k = 0; k < argc; ++k)
112 #pragma omp for simd lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
113 for (int k = 0; k < argc; ++k)
116 #pragma omp for simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
117 for (int k = 0; k < argc; ++k)
121 for (int k = 0; k < argc; ++k)
126 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
127 #pragma omp for simd lastprivate(i) // expected-error {{lastprivate variable must be shared}}
128 for (int k = 0; k < argc; ++k) {
133 #pragma omp parallel shared(i)
134 #pragma omp parallel private(i)
135 #pragma omp for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
136 for (int k = 0; k < argc; ++k)
139 #pragma omp for simd lastprivate(i)
140 for (int k = 0; k < argc; ++k)
147 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
153 int main(int argc, char **argv) {
154 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
155 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
161 int &j = i; // expected-note {{'j' defined here}}
163 #pragma omp for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
164 for (i = 0; i < argc; ++i)
167 #pragma omp for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
168 for (i = 0; i < argc; ++i)
171 #pragma omp for simd lastprivate() // expected-error {{expected expression}}
172 for (i = 0; i < argc; ++i)
175 #pragma omp for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
176 for (i = 0; i < argc; ++i)
179 #pragma omp for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
180 for (i = 0; i < argc; ++i)
183 #pragma omp for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
184 for (i = 0; i < argc; ++i)
187 #pragma omp for simd lastprivate(argc)
188 for (i = 0; i < argc; ++i)
191 #pragma omp for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
192 for (i = 0; i < argc; ++i)
195 #pragma omp for simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
196 for (i = 0; i < argc; ++i)
199 #pragma omp for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
200 for (i = 0; i < argc; ++i)
203 #pragma omp for simd lastprivate(2 * 2) // expected-error {{expected variable name}}
204 for (i = 0; i < argc; ++i)
207 #pragma omp for simd lastprivate(ba)
208 for (i = 0; i < argc; ++i)
211 #pragma omp for simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
212 for (i = 0; i < argc; ++i)
215 #pragma omp for simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
216 for (i = 0; i < argc; ++i)
220 #pragma omp for simd lastprivate(xa) // OK
221 for (i = 0; i < argc; ++i)
224 #pragma omp for simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
225 for (i = 0; i < argc; ++i)
228 #pragma omp for simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
229 for (i = 0; i < argc; ++i)
233 for (i = 0; i < argc; ++i)
236 #pragma omp for simd lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
237 for (i = 0; i < argc; ++i)
240 #pragma omp for simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
241 for (i = 0; i < argc; ++i)
244 #pragma omp for simd lastprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be lastprivate}}
245 for (i = 0; i < argc; ++i)
248 #pragma omp for simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
249 for (i = 0; i < argc; ++i)
252 #pragma omp for simd lastprivate(i) // expected-note {{defined as lastprivate}}
253 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp for simd' directive may not be lastprivate, predetermined as linear}}
255 #pragma omp parallel private(xa) // expected-note {{defined as private}}
256 #pragma omp for simd lastprivate(xa) // expected-error {{lastprivate variable must be shared}}
257 for (i = 0; i < argc; ++i)
259 #pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}}
260 #pragma omp for simd lastprivate(xa) // expected-error {{lastprivate variable must be shared}}
261 for (i = 0; i < argc; ++i)
264 #pragma omp for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
265 for (i = 0; i < argc; ++i)
268 #pragma omp for simd firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
269 for (i = 0; i < argc; ++i)
272 #pragma omp for simd lastprivate(n) firstprivate(n) // OK
273 for (i = 0; i < argc; ++i)
275 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}