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) {
71 #pragma omp target parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
72 for (int k = 0; k < argc; ++k)
74 #pragma omp target parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75 for (int k = 0; k < argc; ++k)
77 #pragma omp target parallel for lastprivate() // expected-error {{expected expression}}
78 for (int k = 0; k < argc; ++k)
80 #pragma omp target parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
81 for (int k = 0; k < argc; ++k)
83 #pragma omp target parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (int k = 0; k < argc; ++k)
86 #pragma omp target parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
87 for (int k = 0; k < argc; ++k)
89 #pragma omp target parallel for lastprivate(argc)
90 for (int k = 0; k < argc; ++k)
92 #pragma omp target parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
93 for (int k = 0; k < argc; ++k)
95 #pragma omp target parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
96 for (int k = 0; k < argc; ++k)
98 #pragma omp target parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
99 for (int k = 0; k < argc; ++k)
101 #pragma omp target parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
102 for (int k = 0; k < argc; ++k)
104 #pragma omp target parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
105 for (int k = 0; k < argc; ++k)
111 #pragma omp target parallel for lastprivate(i)
112 for (int k = 0; k < argc; ++k) {
117 #pragma omp parallel shared(i)
118 #pragma omp parallel private(i)
119 #pragma omp target parallel for lastprivate(j)
120 for (int k = 0; k < argc; ++k)
122 #pragma omp target parallel for lastprivate(i)
123 for (int k = 0; k < argc; ++k)
130 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
136 int main(int argc, char **argv) {
137 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
138 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
145 #pragma omp target parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
146 for (i = 0; i < argc; ++i)
148 #pragma omp target parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
149 for (i = 0; i < argc; ++i)
151 #pragma omp target parallel for lastprivate() // expected-error {{expected expression}}
152 for (i = 0; i < argc; ++i)
154 #pragma omp target parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
155 for (i = 0; i < argc; ++i)
157 #pragma omp target parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
158 for (i = 0; i < argc; ++i)
160 #pragma omp target parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
161 for (i = 0; i < argc; ++i)
163 #pragma omp target parallel for lastprivate(argc)
164 for (i = 0; i < argc; ++i)
166 #pragma omp target parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
167 for (i = 0; i < argc; ++i)
169 #pragma omp target parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
170 for (i = 0; i < argc; ++i)
172 #pragma omp target parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
173 for (i = 0; i < argc; ++i)
175 #pragma omp target parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
176 for (i = 0; i < argc; ++i)
178 #pragma omp target parallel for lastprivate(ba)
179 for (i = 0; i < argc; ++i)
181 #pragma omp target parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
182 for (i = 0; i < argc; ++i)
184 #pragma omp target parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
185 for (i = 0; i < argc; ++i)
188 #pragma omp target parallel for lastprivate(xa) // OK
189 for (i = 0; i < argc; ++i)
191 #pragma omp target parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
192 for (i = 0; i < argc; ++i)
194 #pragma omp target parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
195 for (i = 0; i < argc; ++i)
197 #pragma omp target parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp target parallel for'}}
198 for (i = 0; i < argc; ++i)
200 #pragma omp target parallel for lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
201 for (i = 0; i < argc; ++i)
203 #pragma omp target parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
204 for (i = 0; i < argc; ++i)
206 #pragma omp target parallel for lastprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be lastprivate}}
207 for (i = 0; i < argc; ++i)
209 #pragma omp target parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
210 for (i = 0; i < argc; ++i)
212 #pragma omp target parallel for lastprivate(i)
213 for (i = 0; i < argc; ++i)
215 #pragma omp parallel private(xa)
216 #pragma omp target parallel for lastprivate(xa)
217 for (i = 0; i < argc; ++i)
219 #pragma omp parallel reduction(+ : xa)
220 #pragma omp target parallel for lastprivate(xa)
221 for (i = 0; i < argc; ++i)
223 #pragma omp target parallel for lastprivate(j)
224 for (i = 0; i < argc; ++i)
226 #pragma omp target parallel for firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
227 for (i = 0; i < argc; ++i)
229 #pragma omp target parallel for lastprivate(n) firstprivate(n) // OK
230 for (i = 0; i < argc; ++i)
233 #pragma omp target parallel for lastprivate(si) // OK
234 for (i = 0; i < argc; ++i)
237 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}