Clang Project

clang_source_code/test/OpenMP/target_teams_distribute_lastprivate_messages.cpp
1// RUN: %clang_cc1 -verify -fopenmp %s
2
3// RUN: %clang_cc1 -verify -fopenmp-simd %s
4
5typedef void **omp_allocator_handle_t;
6extern const omp_allocator_handle_t omp_default_mem_alloc;
7extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
8extern const omp_allocator_handle_t omp_const_mem_alloc;
9extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
10extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
11extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
12extern const omp_allocator_handle_t omp_pteam_mem_alloc;
13extern const omp_allocator_handle_t omp_thread_mem_alloc;
14
15void foo() {
16}
17
18bool foobool(int argc) {
19  return argc;
20}
21
22struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
23extern S1 a;
24class S2 {
25  mutable int a;
26
27public:
28  S2() : a(0) {}
29  S2(S2 &s2) : a(s2.a) {}
30  const S2 &operator =(const S2&) const;
31  S2 &operator =(const S2&);
32  static float S2s; // expected-note {{static data member is predetermined as shared}}
33  static const float S2sc; // expected-note {{'S2sc' declared here}}
34};
35const float S2::S2sc = 0;
36const S2 b;
37const S2 ba[5];
38class S3 {
39  int a;
40  S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}}
41
42public:
43  S3() : a(0) {}
44  S3(S3 &s3) : a(s3.a) {}
45};
46const S3 c;         // expected-note {{'c' defined here}}
47const S3 ca[5];     // expected-note {{'ca' defined here}}
48extern const int f; // expected-note {{'f' declared here}}
49class S4 {
50  int a;
51  S4();             // expected-note 3 {{implicitly declared private here}}
52  S4(const S4 &s4);
53
54public:
55  S4(int v) : a(v) {}
56};
57class S5 {
58  int a;
59  S5() : a(0) {} // expected-note {{implicitly declared private here}}
60
61public:
62  S5(const S5 &s5) : a(s5.a) {}
63  S5(int v) : a(v) {}
64};
65class S6 {
66  int a;
67  S6() : a(0) {} // expected-note {{implicitly declared private here}}
68
69public:
70  S6(const S6 &s6) : a(s6.a) {}
71  S6(int v) : a(v) {}
72};
73
74S3 h;
75#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
76
77template <class I, class C>
78int foomain(int argc, char **argv) {
79  I e(4);
80  I g(5);
81  int i;
82  int &j = i;
83#pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
84  for (int k = 0; k < argc; ++k) ++k;
85
86#pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87  for (int k = 0; k < argc; ++k) ++k;
88
89#pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
90  for (int k = 0; k < argc; ++k) ++k;
91
92#pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
93  for (int k = 0; k < argc; ++k) ++k;
94
95#pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96  for (int k = 0; k < argc; ++k) ++k;
97
98#pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
99  for (int k = 0; k < argc; ++k) ++k;
100
101#pragma omp target teams distribute allocate(omp_thread_mem_alloc: argc) lastprivate(argc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target teams distribute' directive}}
102  for (int k = 0; k < argc; ++k) ++k;
103
104#pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
105  for (int k = 0; k < argc; ++k) ++k;
106
107#pragma omp target teams distribute lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
108  for (int k = 0; k < argc; ++k) ++k;
109
110#pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
111  for (int k = 0; k < argc; ++k) ++k;
112
113#pragma omp target teams distribute lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
114  for (int k = 0; k < argc; ++k) ++k;
115
116#pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
117  for (int k = 0; k < argc; ++k) ++k;
118
119  int v = 0;
120#pragma omp target teams distribute lastprivate(i)
121  for (int k = 0; k < argc; ++k) {
122    i = k;
123    v += i;
124  }
125
126#pragma omp target teams distribute lastprivate(j) private(i)
127  for (int k = 0; k < argc; ++k) ++k;
128
129#pragma omp target teams distribute lastprivate(i)
130  for (int k = 0; k < argc; ++k) ++k;
131
132  return 0;
133}
134
135void bar(S4 a[2]) {
136#pragma omp target teams distribute lastprivate(a)
137  for (int i = 0; i < 2; ++i) foo();
138}
139
140namespace A {
141double x;
142#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
143}
144namespace B {
145using A::x;
146}
147
148int main(int argc, char **argv) {
149  const int d = 5;       // expected-note {{'d' defined here}}
150  const int da[5] = {0}; // expected-note {{'da' defined here}}
151  S4 e(4);
152  S5 g(5);
153  S3 m;
154  S6 n(2);
155  int i;
156  int &j = i;
157#pragma omp target teams distribute lastprivate // expected-error {{expected '(' after 'lastprivate'}}
158  for (i = 0; i < argc; ++i) foo();
159
160#pragma omp target teams distribute lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
161  for (i = 0; i < argc; ++i) foo();
162
163#pragma omp target teams distribute lastprivate() // expected-error {{expected expression}}
164  for (i = 0; i < argc; ++i) foo();
165
166#pragma omp target teams distribute lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
167  for (i = 0; i < argc; ++i) foo();
168
169#pragma omp target teams distribute lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170  for (i = 0; i < argc; ++i) foo();
171
172#pragma omp target teams distribute lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
173  for (i = 0; i < argc; ++i) foo();
174
175#pragma omp target teams distribute lastprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
176  for (i = 0; i < argc; ++i) foo();
177
178#pragma omp target teams distribute lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
179  for (i = 0; i < argc; ++i) foo();
180
181#pragma omp target teams distribute 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}}
182  for (i = 0; i < argc; ++i) foo();
183
184#pragma omp target teams distribute lastprivate(argv[1]) // expected-error {{expected variable name}}
185  for (i = 0; i < argc; ++i) foo();
186
187#pragma omp target teams distribute lastprivate(2 * 2) // expected-error {{expected variable name}}
188  for (i = 0; i < argc; ++i) foo();
189
190#pragma omp target teams distribute lastprivate(ba)
191  for (i = 0; i < argc; ++i) foo();
192
193#pragma omp target teams distribute lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}}
194  for (i = 0; i < argc; ++i) foo();
195
196#pragma omp target teams distribute lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}}
197  for (i = 0; i < argc; ++i) foo();
198
199  int xa;
200#pragma omp target teams distribute lastprivate(xa) // OK
201  for (i = 0; i < argc; ++i) foo();
202
203#pragma omp target teams distribute lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
204  for (i = 0; i < argc; ++i) foo();
205
206#pragma omp target teams distribute lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}}
207  for (i = 0; i < argc; ++i) foo();
208
209#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'}}
210  for (i = 0; i < argc; ++i) foo();
211
212#pragma omp target teams distribute lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
213  for (i = 0; i < argc; ++i) foo();
214
215#pragma omp target teams distribute lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
216  for (i = 0; i < argc; ++i) foo();
217
218#pragma omp target teams distribute lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
219  for (i = 0; i < argc; ++i) foo();
220
221#pragma omp target teams distribute private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
222  for (i = 0; i < argc; ++i) foo();
223
224#pragma omp target teams distribute lastprivate(xa)
225  for (i = 0; i < argc; ++i) foo();
226
227#pragma omp target teams distribute lastprivate(j)
228  for (i = 0; i < argc; ++i) foo();
229
230// expected-error@+1 {{firstprivate variable cannot be lastprivate}} expected-note@+1 {{defined as firstprivate}}
231#pragma omp target teams distribute firstprivate(m) lastprivate(m)
232  for (i = 0; i < argc; ++i) foo();
233
234// expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
235#pragma omp target teams distribute lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}}
236  for (i = 0; i < argc; ++i) foo();
237
238  static int si;
239#pragma omp target teams distribute  lastprivate(si) // OK
240  for (i = 0; i < argc; ++i) si = i + 1;
241
242  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
243}
244