]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_teams_distribute_lastprivate_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_teams_distribute_lastprivate_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 void foo() {
4 }
5
6 bool foobool(int argc) {
7   return argc;
8 }
9
10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14
15 public:
16   S2() : a(0) {}
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;
22 };
23 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
24 const S2 b;
25 const S2 ba[5];
26 class S3 {
27   int a;
28   S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
29
30 public:
31   S3() : a(0) {}
32   S3(S3 &s3) : a(s3.a) {}
33 };
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}}
37 class S4 {
38   int a;
39   S4();             // expected-note 3 {{implicitly declared private here}}
40   S4(const S4 &s4);
41
42 public:
43   S4(int v) : a(v) {}
44 };
45 class S5 {
46   int a;
47   S5() : a(0) {} // expected-note {{implicitly declared private here}}
48
49 public:
50   S5(const S5 &s5) : a(s5.a) {}
51   S5(int v) : a(v) {}
52 };
53 class S6 {
54   int a;
55   S6() : a(0) {}
56
57 public:
58   S6(const S6 &s6) : a(s6.a) {}
59   S6(int v) : a(v) {}
60 };
61
62 S3 h;
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
64
65 template <class I, class C>
66 int foomain(int argc, char **argv) {
67   I e(4);
68   I g(5);
69   int i;
70   int &j = i;
71 #pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
72   for (int k = 0; k < argc; ++k) ++k;
73
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;
76
77 #pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
78   for (int k = 0; k < argc; ++k) ++k;
79
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;
82
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;
85
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;
88
89 #pragma omp target teams distribute lastprivate(argc)
90   for (int k = 0; k < argc; ++k) ++k;
91
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;
94
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;
97
98 #pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
99   for (int k = 0; k < argc; ++k) ++k;
100
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;
103
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;
106
107   int v = 0;
108 #pragma omp target teams distribute lastprivate(i)
109   for (int k = 0; k < argc; ++k) {
110     i = k;
111     v += i;
112   }
113
114 #pragma omp target teams distribute lastprivate(j) private(i)
115   for (int k = 0; k < argc; ++k) ++k;
116
117 #pragma omp target teams distribute lastprivate(i)
118   for (int k = 0; k < argc; ++k) ++k;
119
120   return 0;
121 }
122
123 void bar(S4 a[2]) {
124 #pragma omp target teams distribute lastprivate(a)
125   for (int i = 0; i < 2; ++i) foo();
126 }
127
128 namespace A {
129 double x;
130 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
131 }
132 namespace B {
133 using A::x;
134 }
135
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}}
139   S4 e(4);
140   S5 g(5);
141   S3 m;
142   S6 n(2);
143   int i;
144   int &j = i;
145 #pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
146   for (i = 0; i < argc; ++i) foo();
147
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();
150
151 #pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
152   for (i = 0; i < argc; ++i) foo();
153
154 #pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
155   for (i = 0; i < argc; ++i) foo();
156
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();
159
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();
162
163 #pragma omp target teams distribute lastprivate(argc)
164   for (i = 0; i < argc; ++i) foo();
165
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();
168
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();
171
172 #pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
173   for (i = 0; i < argc; ++i) foo();
174
175 #pragma omp target teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}}
176   for (i = 0; i < argc; ++i) foo();
177
178 #pragma omp target teams distribute lastprivate(ba)
179   for (i = 0; i < argc; ++i) foo();
180
181 #pragma omp target teams distribute lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
182   for (i = 0; i < argc; ++i) foo();
183
184 #pragma omp target teams distribute lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
185   for (i = 0; i < argc; ++i) foo();
186
187   int xa;
188 #pragma omp target teams distribute lastprivate(xa) // OK
189   for (i = 0; i < argc; ++i) foo();
190
191 #pragma omp target teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
192   for (i = 0; i < argc; ++i) foo();
193
194 #pragma omp target teams distribute lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
195   for (i = 0; i < argc; ++i) foo();
196
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();
199
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();
202
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();
205
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();
208
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();
211
212 #pragma omp target teams distribute lastprivate(xa)
213   for (i = 0; i < argc; ++i) foo();
214
215 #pragma omp target teams distribute lastprivate(j)
216   for (i = 0; i < argc; ++i) foo();
217
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();
220
221 #pragma omp target teams distribute lastprivate(n) firstprivate(n) // OK
222   for (i = 0; i < argc; ++i) foo();
223
224   static int si;
225 #pragma omp target teams distribute  lastprivate(si) // OK
226   for (i = 0; i < argc; ++i) si = i + 1;
227
228   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
229 }