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 const S2 &operator =(const S2&) const;
19 S2 &operator =(const S2&);
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 teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
72 for (int k = 0; k < argc; ++k) ++k;
74 #pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75 for (int k = 0; k < argc; ++k) ++k;
77 #pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
78 for (int k = 0; k < argc; ++k) ++k;
80 #pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
81 for (int k = 0; k < argc; ++k) ++k;
83 #pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (int k = 0; k < argc; ++k) ++k;
86 #pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
87 for (int k = 0; k < argc; ++k) ++k;
89 #pragma omp target teams distribute lastprivate(argc)
90 for (int k = 0; k < argc; ++k) ++k;
92 #pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
93 for (int k = 0; k < argc; ++k) ++k;
95 #pragma omp target teams distribute lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
96 for (int k = 0; k < argc; ++k) ++k;
98 #pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
99 for (int k = 0; k < argc; ++k) ++k;
101 #pragma omp target teams distribute lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
102 for (int k = 0; k < argc; ++k) ++k;
104 #pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
105 for (int k = 0; k < argc; ++k) ++k;
108 #pragma omp target teams distribute lastprivate(i)
109 for (int k = 0; k < argc; ++k) {
114 #pragma omp target teams distribute lastprivate(j) private(i)
115 for (int k = 0; k < argc; ++k) ++k;
117 #pragma omp target teams distribute lastprivate(i)
118 for (int k = 0; k < argc; ++k) ++k;
124 #pragma omp target teams distribute lastprivate(a)
125 for (int i = 0; i < 2; ++i) foo();
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 teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
146 for (i = 0; i < argc; ++i) foo();
148 #pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
149 for (i = 0; i < argc; ++i) foo();
151 #pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
152 for (i = 0; i < argc; ++i) foo();
154 #pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
155 for (i = 0; i < argc; ++i) foo();
157 #pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
158 for (i = 0; i < argc; ++i) foo();
160 #pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
161 for (i = 0; i < argc; ++i) foo();
163 #pragma omp target teams distribute lastprivate(argc)
164 for (i = 0; i < argc; ++i) foo();
166 #pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
167 for (i = 0; i < argc; ++i) foo();
169 #pragma omp target teams distribute 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) foo();
172 #pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
173 for (i = 0; i < argc; ++i) foo();
175 #pragma omp target teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}}
176 for (i = 0; i < argc; ++i) foo();
178 #pragma omp target teams distribute lastprivate(ba)
179 for (i = 0; i < argc; ++i) foo();
181 #pragma omp target teams distribute lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
182 for (i = 0; i < argc; ++i) foo();
184 #pragma omp target teams distribute lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
185 for (i = 0; i < argc; ++i) foo();
188 #pragma omp target teams distribute lastprivate(xa) // OK
189 for (i = 0; i < argc; ++i) foo();
191 #pragma omp target teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
192 for (i = 0; i < argc; ++i) foo();
194 #pragma omp target teams distribute lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
195 for (i = 0; i < argc; ++i) foo();
197 #pragma omp target teams distribute lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
198 for (i = 0; i < argc; ++i) foo();
200 #pragma omp target teams distribute lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
201 for (i = 0; i < argc; ++i) foo();
203 #pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
204 for (i = 0; i < argc; ++i) foo();
206 #pragma omp target teams distribute lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
207 for (i = 0; i < argc; ++i) foo();
209 #pragma omp target teams distribute private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
210 for (i = 0; i < argc; ++i) foo();
212 #pragma omp target teams distribute lastprivate(xa)
213 for (i = 0; i < argc; ++i) foo();
215 #pragma omp target teams distribute lastprivate(j)
216 for (i = 0; i < argc; ++i) foo();
218 #pragma omp target teams distribute firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
219 for (i = 0; i < argc; ++i) foo();
221 #pragma omp target teams distribute lastprivate(n) firstprivate(n) // OK
222 for (i = 0; i < argc; ++i) foo();
225 #pragma omp target teams distribute lastprivate(si) // OK
226 for (i = 0; i < argc; ++i) si = i + 1;
228 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}