[libc][test] Adjust header paths in tests (#119623)
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_parallel_for_lastprivate_messages.cpp
blobde6fef5aa4d8100e91eb2fee6abf6d94bd0ead03
1 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=40 -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=45 -fopenmp %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp %s -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=45 -fopenmp-simd %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd %s -Wuninitialized
9 #pragma omp requires dynamic_allocators
10 typedef void **omp_allocator_handle_t;
11 extern const omp_allocator_handle_t omp_null_allocator;
12 extern const omp_allocator_handle_t omp_default_mem_alloc;
13 extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
14 extern const omp_allocator_handle_t omp_const_mem_alloc;
15 extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
16 extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
17 extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
18 extern const omp_allocator_handle_t omp_pteam_mem_alloc;
19 extern const omp_allocator_handle_t omp_thread_mem_alloc;
21 void foo() {
24 bool foobool(int argc) {
25 return argc;
28 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
29 extern S1 a;
30 class S2 {
31 mutable int a;
33 public:
34 S2() : a(0) {}
35 S2(S2 &s2) : a(s2.a) {}
36 const S2 &operator =(const S2&) const;
37 S2 &operator =(const S2&);
38 static float S2s; // expected-note {{static data member is predetermined as shared}}
39 static const float S2sc; // expected-note {{'S2sc' declared here}}
41 const float S2::S2sc = 0;
42 const S2 b;
43 const S2 ba[5];
44 class S3 {
45 int a;
46 S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}}
48 public:
49 S3() : a(0) {}
50 S3(S3 &s3) : a(s3.a) {}
52 const S3 c; // expected-note {{'c' defined here}}
53 const S3 ca[5]; // expected-note {{'ca' defined here}}
54 extern const int f; // expected-note {{'f' declared here}}
55 class S4 {
56 int a;
57 S4(); // expected-note 3 {{implicitly declared private here}}
58 S4(const S4 &s4);
60 public:
61 S4(int v) : a(v) {}
63 class S5 {
64 int a;
65 S5() : a(0) {} // expected-note {{implicitly declared private here}}
67 public:
68 S5(const S5 &s5) : a(s5.a) {}
69 S5(int v) : a(v) {}
71 class S6 {
72 int a;
73 S6() : a(0) {} // expected-note {{implicitly declared private here}}
75 public:
76 S6(const S6 &s6) : a(s6.a) {}
77 S6(int v) : a(v) {}
80 S3 h;
81 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
83 template <class I, class C>
84 int foomain(int argc, char **argv) {
85 I e(4);
86 I g(5);
87 int i;
88 int &j = i;
89 #pragma omp target teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
90 for (int k = 0; k < argc; ++k) ++k;
92 #pragma omp target teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (int k = 0; k < argc; ++k) ++k;
95 #pragma omp target teams distribute parallel for lastprivate() // expected-error {{expected expression}}
96 for (int k = 0; k < argc; ++k) ++k;
98 #pragma omp target teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
99 for (int k = 0; k < argc; ++k) ++k;
101 #pragma omp target teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
102 for (int k = 0; k < argc; ++k) ++k;
104 #pragma omp target teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
105 for (int k = 0; k < argc; ++k) ++k;
107 #pragma omp target teams distribute parallel for 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 '('}}
108 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp target teams distribute parallel for lastprivate(conditional: argc) lastprivate(conditional: // expected-error 2 {{use of undeclared identifier 'conditional'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
111 for (int k = 0; k < argc; ++k) ++k;
112 #pragma omp target teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
113 for (int k = 0; k < argc; ++k) ++k;
115 #pragma omp target teams distribute parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
116 for (int k = 0; k < argc; ++k) ++k;
118 #pragma omp target teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
119 for (int k = 0; k < argc; ++k) ++k;
121 #pragma omp target teams distribute parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
122 for (int k = 0; k < argc; ++k) ++k;
124 #pragma omp target teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
125 for (int k = 0; k < argc; ++k) ++k;
127 int v = 0;
128 #pragma omp target teams distribute parallel for allocate(omp_thread_mem_alloc: i) lastprivate(i) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target teams distribute parallel for' directive}}
129 for (int k = 0; k < argc; ++k) {
130 i = k;
131 v += i;
134 #pragma omp target teams distribute parallel for lastprivate(j) private(i)
135 for (int k = 0; k < argc; ++k) ++k;
137 #pragma omp target teams distribute parallel for lastprivate(i)
138 for (int k = 0; k < argc; ++k) ++k;
140 return 0;
143 void bar(S4 a[2]) {
144 #pragma omp target teams distribute parallel for lastprivate(a)
145 for (int i = 0; i < 2; ++i) foo();
148 namespace A {
149 double x;
150 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
152 namespace B {
153 using A::x;
156 int main(int argc, char **argv) {
157 const int d = 5; // expected-note {{'d' defined here}}
158 const int da[5] = {0}; // expected-note {{'da' defined here}}
159 S4 e(4);
160 S5 g(5);
161 S3 m;
162 S6 n(2);
163 int i;
164 int &j = i;
165 float k;
166 #pragma omp target teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
167 for (i = 0; i < argc; ++i) foo();
169 #pragma omp target teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170 for (i = 0; i < argc; ++i) foo();
172 #pragma omp target teams distribute parallel for lastprivate() // expected-error {{expected expression}}
173 for (i = 0; i < argc; ++i) foo();
175 #pragma omp target teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
176 for (i = 0; i < argc; ++i) foo();
178 #pragma omp target teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
179 for (i = 0; i < argc; ++i) foo();
181 #pragma omp target teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
182 for (i = 0; i < argc; ++i) foo();
184 #pragma omp target teams distribute parallel for lastprivate(argc)
185 for (i = 0; i < argc; ++i) foo();
187 #pragma omp target teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
188 for (i = 0; i < argc; ++i) foo();
190 #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}}
191 for (i = 0; i < argc; ++i) foo();
193 #pragma omp target teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
194 for (i = 0; i < argc; ++i) foo();
196 #pragma omp target teams distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
197 for (i = 0; i < argc; ++i) foo();
199 #pragma omp target teams distribute parallel for lastprivate(ba)
200 for (i = 0; i < argc; ++i) foo();
202 #pragma omp target teams distribute parallel for lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}}
203 for (i = 0; i < argc; ++i) foo();
205 #pragma omp target teams distribute parallel for lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}}
206 for (i = 0; i < argc; ++i) foo();
208 int xa;
209 #pragma omp target teams distribute parallel for lastprivate(xa) // OK
210 for (i = 0; i < argc; ++i) foo();
212 #pragma omp target teams distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
213 for (i = 0; i < argc; ++i) foo();
215 #pragma omp target teams distribute parallel for lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}}
216 for (i = 0; i < argc; ++i) foo();
218 #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'}}
219 for (i = 0; i < argc; ++i) foo();
221 #pragma omp target teams distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
222 for (i = 0; i < argc; ++i) foo();
224 #pragma omp target teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
225 for (i = 0; i < argc; ++i) foo();
227 #pragma omp target teams distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
228 for (i = 0; i < argc; ++i) foo();
230 #pragma omp target teams distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
231 for (i = 0; i < argc; ++i) foo();
233 #pragma omp target teams distribute parallel for lastprivate(xa)
234 for (i = 0; i < argc; ++i) foo();
236 #pragma omp target teams distribute parallel for lastprivate(j)
237 for (i = 0; i < argc; ++i) foo();
239 // expected-error@+1 {{firstprivate variable cannot be lastprivate}} expected-note@+1 {{defined as firstprivate}}
240 #pragma omp target teams distribute parallel for firstprivate(m) lastprivate(m)
241 for (i = 0; i < argc; ++i) foo();
243 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
244 #pragma omp target teams distribute parallel for lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}}
245 for (i = 0; i < argc; ++i) foo();
247 static int si;
248 #pragma omp target teams distribute parallel for lastprivate(si) // OK
249 for (i = 0; i < argc; ++i) si = i + 1;
251 #pragma omp target teams distribute parallel for lastprivate(k) map(k) // le45-error {{lastprivate variable cannot be in a map clause in '#pragma omp target teams distribute parallel for' directive}} le45-note {{defined as lastprivate}}
252 for (i = 0; i < argc; ++i) foo();
254 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}