1 // RUN: %clang_cc1 -verify -fopenmp %s
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
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 {{'S2sc' declared here}}
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 {{'c' defined here}}
37 const S3 ca[5]; // expected-note {{'ca' defined here}}
38 extern const int f; // expected-note {{'f' declared here}}
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) {
73 #pragma omp target teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
74 for (int k = 0; k < argc; ++k) ++k;
76 #pragma omp target teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 for (int k = 0; k < argc; ++k) ++k;
79 #pragma omp target teams distribute parallel for lastprivate() // expected-error {{expected expression}}
80 for (int k = 0; k < argc; ++k) ++k;
82 #pragma omp target teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (int k = 0; k < argc; ++k) ++k;
85 #pragma omp target teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for (int k = 0; k < argc; ++k) ++k;
88 #pragma omp target teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
89 for (int k = 0; k < argc; ++k) ++k;
91 #pragma omp target teams distribute parallel for lastprivate(argc)
92 for (int k = 0; k < argc; ++k) ++k;
94 #pragma omp target teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
95 for (int k = 0; k < argc; ++k) ++k;
97 #pragma omp target teams distribute parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
98 for (int k = 0; k < argc; ++k) ++k;
100 #pragma omp target teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
101 for (int k = 0; k < argc; ++k) ++k;
103 #pragma omp target teams distribute parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
104 for (int k = 0; k < argc; ++k) ++k;
106 #pragma omp target teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
107 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp target teams distribute parallel for lastprivate(i)
111 for (int k = 0; k < argc; ++k) {
116 #pragma omp target teams distribute parallel for lastprivate(j) private(i)
117 for (int k = 0; k < argc; ++k) ++k;
119 #pragma omp target teams distribute parallel for lastprivate(i)
120 for (int k = 0; k < argc; ++k) ++k;
126 #pragma omp target teams distribute parallel for lastprivate(a)
127 for (int i = 0; i < 2; ++i) foo();
132 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
138 int main(int argc, char **argv) {
139 const int d = 5; // expected-note {{'d' defined here}}
140 const int da[5] = {0}; // expected-note {{'da' defined here}}
148 #pragma omp target teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
149 for (i = 0; i < argc; ++i) foo();
151 #pragma omp target teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
152 for (i = 0; i < argc; ++i) foo();
154 #pragma omp target teams distribute parallel for lastprivate() // expected-error {{expected expression}}
155 for (i = 0; i < argc; ++i) foo();
157 #pragma omp target teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
158 for (i = 0; i < argc; ++i) foo();
160 #pragma omp target teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
161 for (i = 0; i < argc; ++i) foo();
163 #pragma omp target teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
164 for (i = 0; i < argc; ++i) foo();
166 #pragma omp target teams distribute parallel for lastprivate(argc)
167 for (i = 0; i < argc; ++i) foo();
169 #pragma omp target teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
170 for (i = 0; i < argc; ++i) foo();
172 #pragma omp target teams distribute parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be lastprivate}} expected-error 2 {{const-qualified variable cannot be lastprivate}}
173 for (i = 0; i < argc; ++i) foo();
175 #pragma omp target teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
176 for (i = 0; i < argc; ++i) foo();
178 #pragma omp target teams distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
179 for (i = 0; i < argc; ++i) foo();
181 #pragma omp target teams distribute parallel for lastprivate(ba)
182 for (i = 0; i < argc; ++i) foo();
184 #pragma omp target teams distribute parallel for lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}}
185 for (i = 0; i < argc; ++i) foo();
187 #pragma omp target teams distribute parallel for lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}}
188 for (i = 0; i < argc; ++i) foo();
191 #pragma omp target teams distribute parallel for lastprivate(xa) // OK
192 for (i = 0; i < argc; ++i) foo();
194 #pragma omp target teams distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
195 for (i = 0; i < argc; ++i) foo();
197 #pragma omp target teams distribute parallel for lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}}
198 for (i = 0; i < argc; ++i) foo();
200 #pragma omp target teams distribute 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) foo();
203 #pragma omp target teams distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
204 for (i = 0; i < argc; ++i) foo();
206 #pragma omp target teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
207 for (i = 0; i < argc; ++i) foo();
209 #pragma omp target teams distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
210 for (i = 0; i < argc; ++i) foo();
212 #pragma omp target teams distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
213 for (i = 0; i < argc; ++i) foo();
215 #pragma omp target teams distribute parallel for lastprivate(xa)
216 for (i = 0; i < argc; ++i) foo();
218 #pragma omp target teams distribute parallel for lastprivate(j)
219 for (i = 0; i < argc; ++i) foo();
221 // expected-error@+1 {{firstprivate variable cannot be lastprivate}} expected-note@+1 {{defined as firstprivate}}
222 #pragma omp target teams distribute parallel for firstprivate(m) lastprivate(m)
223 for (i = 0; i < argc; ++i) foo();
225 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
226 #pragma omp target teams distribute parallel for lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}}
227 for (i = 0; i < argc; ++i) foo();
230 #pragma omp target teams distribute parallel for lastprivate(si) // OK
231 for (i = 0; i < argc; ++i) si = i + 1;
233 #pragma omp target teams distribute parallel for lastprivate(k) map(k) // expected-error {{lastprivate variable cannot be in a map clause in '#pragma omp target teams distribute parallel for' directive}} expected-note {{defined as lastprivate}}
234 for (i = 0; i < argc; ++i) foo();
236 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}