1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target
8 bool foobool(int argc) {
12 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
19 S2(S2 &s2) : a(s2.a) {}
20 const S2 &operator =(const S2&) const;
21 S2 &operator =(const S2&);
22 static float S2s; // expected-note {{static data member is predetermined as shared}}
23 static const float S2sc; // expected-note {{static data member is predetermined as shared}}
25 const float S2::S2sc = 0;
30 S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}}
34 S3(S3 &s3) : a(s3.a) {}
36 const S3 c; // expected-note {{global variable is predetermined as shared}}
37 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
38 extern const int f; // expected-note {{global variable is predetermined as shared}}
41 S4(); // expected-note 3 {{implicitly declared private here}}
49 S5() : a(0) {} // expected-note {{implicitly declared private here}}
52 S5(const S5 &s5) : a(s5.a) {}
57 S6() : a(0) {} // expected-note {{implicitly declared private here}}
60 S6(const S6 &s6) : a(s6.a) {}
65 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
67 template <class I, class C>
68 int foomain(int argc, char **argv) {
74 #pragma omp teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
75 for (int k = 0; k < argc; ++k) ++k;
78 #pragma omp teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
79 for (int k = 0; k < argc; ++k) ++k;
82 #pragma omp teams distribute lastprivate() // expected-error {{expected expression}}
83 for (int k = 0; k < argc; ++k) ++k;
86 #pragma omp teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
87 for (int k = 0; k < argc; ++k) ++k;
90 #pragma omp teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
91 for (int k = 0; k < argc; ++k) ++k;
94 #pragma omp teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
95 for (int k = 0; k < argc; ++k) ++k;
98 #pragma omp teams distribute lastprivate(argc)
99 for (int k = 0; k < argc; ++k) ++k;
102 #pragma omp teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
103 for (int k = 0; k < argc; ++k) ++k;
106 #pragma omp teams distribute lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
107 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
111 for (int k = 0; k < argc; ++k) ++k;
114 #pragma omp teams distribute lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
115 for (int k = 0; k < argc; ++k) ++k;
118 #pragma omp teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
119 for (int k = 0; k < argc; ++k) ++k;
123 #pragma omp teams distribute lastprivate(i)
124 for (int k = 0; k < argc; ++k) {
130 #pragma omp teams distribute lastprivate(j) private(i)
131 for (int k = 0; k < argc; ++k) ++k;
134 #pragma omp teams distribute lastprivate(i)
135 for (int k = 0; k < argc; ++k) ++k;
142 #pragma omp teams distribute lastprivate(a)
143 for (int i = 0; i < 2; ++i) foo();
148 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
154 int main(int argc, char **argv) {
155 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
156 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
164 #pragma omp teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
165 for (i = 0; i < argc; ++i) foo();
168 #pragma omp teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
169 for (i = 0; i < argc; ++i) foo();
172 #pragma omp teams distribute lastprivate() // expected-error {{expected expression}}
173 for (i = 0; i < argc; ++i) foo();
176 #pragma omp teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
177 for (i = 0; i < argc; ++i) foo();
180 #pragma omp teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
181 for (i = 0; i < argc; ++i) foo();
184 #pragma omp teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
185 for (i = 0; i < argc; ++i) foo();
188 #pragma omp teams distribute lastprivate(argc)
189 for (i = 0; i < argc; ++i) foo();
192 #pragma omp teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
193 for (i = 0; i < argc; ++i) foo();
196 #pragma omp teams distribute lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
197 for (i = 0; i < argc; ++i) foo();
200 #pragma omp teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
201 for (i = 0; i < argc; ++i) foo();
204 #pragma omp teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}}
205 for (i = 0; i < argc; ++i) foo();
208 #pragma omp teams distribute lastprivate(ba)
209 for (i = 0; i < argc; ++i) foo();
212 #pragma omp teams distribute lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
213 for (i = 0; i < argc; ++i) foo();
216 #pragma omp teams distribute lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
217 for (i = 0; i < argc; ++i) foo();
221 #pragma omp teams distribute lastprivate(xa) // OK
222 for (i = 0; i < argc; ++i) foo();
225 #pragma omp teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
226 for (i = 0; i < argc; ++i) foo();
229 #pragma omp teams distribute lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
230 for (i = 0; i < argc; ++i) foo();
233 #pragma omp teams distribute lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
234 for (i = 0; i < argc; ++i) foo();
237 #pragma omp teams distribute lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
238 for (i = 0; i < argc; ++i) foo();
241 #pragma omp teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
242 for (i = 0; i < argc; ++i) foo();
245 #pragma omp teams distribute lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
246 for (i = 0; i < argc; ++i) foo();
249 #pragma omp teams distribute private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
250 for (i = 0; i < argc; ++i) foo();
253 #pragma omp teams distribute lastprivate(xa)
254 for (i = 0; i < argc; ++i) foo();
257 #pragma omp teams distribute lastprivate(j)
258 for (i = 0; i < argc; ++i) foo();
260 // expected-error@+2 {{firstprivate variable cannot be lastprivate}} expected-note@+2 {{defined as firstprivate}}
262 #pragma omp teams distribute firstprivate(m) lastprivate(m)
263 for (i = 0; i < argc; ++i) foo();
265 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
267 #pragma omp teams distribute lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}}
268 for (i = 0; i < argc; ++i) foo();
272 #pragma omp teams distribute lastprivate(si) // OK
273 for (i = 0; i < argc; ++i) si = i + 1;
275 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}