]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/teams_distribute_lastprivate_messages.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / OpenMP / teams_distribute_lastprivate_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target
4
5 void foo() {
6 }
7
8 bool foobool(int argc) {
9   return argc;
10 }
11
12 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
13 extern S1 a;
14 class S2 {
15   mutable int a;
16
17 public:
18   S2() : a(0) {}
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}}
24 };
25 const float S2::S2sc = 0;
26 const S2 b;
27 const S2 ba[5];
28 class S3 {
29   int a;
30   S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}}
31
32 public:
33   S3() : a(0) {}
34   S3(S3 &s3) : a(s3.a) {}
35 };
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}}
39 class S4 {
40   int a;
41   S4();             // expected-note 3 {{implicitly declared private here}}
42   S4(const S4 &s4);
43
44 public:
45   S4(int v) : a(v) {}
46 };
47 class S5 {
48   int a;
49   S5() : a(0) {} // expected-note {{implicitly declared private here}}
50
51 public:
52   S5(const S5 &s5) : a(s5.a) {}
53   S5(int v) : a(v) {}
54 };
55 class S6 {
56   int a;
57   S6() : a(0) {} // expected-note {{implicitly declared private here}}
58
59 public:
60   S6(const S6 &s6) : a(s6.a) {}
61   S6(int v) : a(v) {}
62 };
63
64 S3 h;
65 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
66
67 template <class I, class C>
68 int foomain(int argc, char **argv) {
69   I e(4);
70   I g(5);
71   int i;
72   int &j = i;
73 #pragma omp target
74 #pragma omp teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
75   for (int k = 0; k < argc; ++k) ++k;
76
77 #pragma omp target
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;
80
81 #pragma omp target
82 #pragma omp teams distribute lastprivate() // expected-error {{expected expression}}
83   for (int k = 0; k < argc; ++k) ++k;
84
85 #pragma omp target
86 #pragma omp teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
87   for (int k = 0; k < argc; ++k) ++k;
88
89 #pragma omp target
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;
92
93 #pragma omp target
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;
96
97 #pragma omp target
98 #pragma omp teams distribute lastprivate(argc)
99   for (int k = 0; k < argc; ++k) ++k;
100
101 #pragma omp target
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;
104
105 #pragma omp target
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;
108
109 #pragma omp target
110 #pragma omp teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
111   for (int k = 0; k < argc; ++k) ++k;
112
113 #pragma omp target
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;
116
117 #pragma omp target
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;
120
121   int v = 0;
122 #pragma omp target
123 #pragma omp teams distribute lastprivate(i)
124   for (int k = 0; k < argc; ++k) {
125     i = k;
126     v += i;
127   }
128
129 #pragma omp target
130 #pragma omp teams distribute lastprivate(j) private(i)
131   for (int k = 0; k < argc; ++k) ++k;
132
133 #pragma omp target
134 #pragma omp teams distribute lastprivate(i)
135   for (int k = 0; k < argc; ++k) ++k;
136
137   return 0;
138 }
139
140 void bar(S4 a[2]) {
141 #pragma omp target
142 #pragma omp teams distribute lastprivate(a)
143   for (int i = 0; i < 2; ++i) foo();
144 }
145
146 namespace A {
147 double x;
148 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
149 }
150 namespace B {
151 using A::x;
152 }
153
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}}
157   S4 e(4);
158   S5 g(5);
159   S3 m;
160   S6 n(2);
161   int i;
162   int &j = i;
163 #pragma omp target
164 #pragma omp teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
165   for (i = 0; i < argc; ++i) foo();
166
167 #pragma omp target
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();
170
171 #pragma omp target
172 #pragma omp teams distribute lastprivate() // expected-error {{expected expression}}
173   for (i = 0; i < argc; ++i) foo();
174
175 #pragma omp target
176 #pragma omp teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
177   for (i = 0; i < argc; ++i) foo();
178
179 #pragma omp target
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();
182
183 #pragma omp target
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();
186
187 #pragma omp target
188 #pragma omp teams distribute lastprivate(argc)
189   for (i = 0; i < argc; ++i) foo();
190
191 #pragma omp target
192 #pragma omp teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
193   for (i = 0; i < argc; ++i) foo();
194
195 #pragma omp target
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();
198
199 #pragma omp target
200 #pragma omp teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
201   for (i = 0; i < argc; ++i) foo();
202
203 #pragma omp target
204 #pragma omp teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}}
205   for (i = 0; i < argc; ++i) foo();
206
207 #pragma omp target
208 #pragma omp teams distribute lastprivate(ba)
209   for (i = 0; i < argc; ++i) foo();
210
211 #pragma omp target
212 #pragma omp teams distribute lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
213   for (i = 0; i < argc; ++i) foo();
214
215 #pragma omp target
216 #pragma omp teams distribute lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
217   for (i = 0; i < argc; ++i) foo();
218
219   int xa;
220 #pragma omp target
221 #pragma omp teams distribute lastprivate(xa) // OK
222   for (i = 0; i < argc; ++i) foo();
223
224 #pragma omp target
225 #pragma omp teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
226   for (i = 0; i < argc; ++i) foo();
227
228 #pragma omp target
229 #pragma omp teams distribute lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
230   for (i = 0; i < argc; ++i) foo();
231
232 #pragma omp target
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();
235
236 #pragma omp target
237 #pragma omp teams distribute lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
238   for (i = 0; i < argc; ++i) foo();
239
240 #pragma omp target
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();
243
244 #pragma omp target
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();
247
248 #pragma omp target
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();
251
252 #pragma omp target
253 #pragma omp teams distribute lastprivate(xa)
254   for (i = 0; i < argc; ++i) foo();
255
256 #pragma omp target
257 #pragma omp teams distribute lastprivate(j)
258   for (i = 0; i < argc; ++i) foo();
259
260 // expected-error@+2 {{firstprivate variable cannot be lastprivate}} expected-note@+2 {{defined as firstprivate}}
261 #pragma omp target
262 #pragma omp teams distribute firstprivate(m) lastprivate(m)
263   for (i = 0; i < argc; ++i) foo();
264
265 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
266 #pragma omp target
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();
269
270   static int si;
271 #pragma omp target
272 #pragma omp teams distribute  lastprivate(si) // OK
273   for (i = 0; i < argc; ++i) si = i + 1;
274
275   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
276 }