Clang Project

clang_source_code/test/OpenMP/target_parallel_for_simd_firstprivate_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(const S2 &s2) : a(s2.a) {}
30  static float S2s;
31  static const float S2sc;
32};
33const float S2::S2sc = 0;
34const S2 b;
35const S2 ba[5];
36class S3 {
37  int a;
38  S3 &operator=(const S3 &s3);
39
40public:
41  S3() : a(0) {}
42  S3(const S3 &s3) : a(s3.a) {}
43};
44const S3 c;
45const S3 ca[5];
46extern const int f;
47class S4 {
48  int a;
49  S4();
50  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
51
52public:
53  S4(int v) : a(v) {}
54};
55class S5 {
56  int a;
57  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
58
59public:
60  S5() : a(0) {}
61  S5(int v) : a(v) {}
62};
63class S6 {
64  int a;
65  S6() : a(0) {}
66
67public:
68  S6(const S6 &s6) : a(s6.a) {}
69  S6(int v) : a(v) {}
70};
71
72S3 h;
73#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
74
75template <class I, class C>
76int foomain(int argc, char **argv) {
77  I e(4);
78  C g(5);
79  int i;
80  int &j = i;
81#pragma omp target parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
82  for (int k = 0; k < argc; ++k)
83    ++k;
84#pragma omp target parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
85  for (int k = 0; k < argc; ++k)
86    ++k;
87#pragma omp target parallel for simd firstprivate() // expected-error {{expected expression}}
88  for (int k = 0; k < argc; ++k)
89    ++k;
90#pragma omp target parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
91  for (int k = 0; k < argc; ++k)
92    ++k;
93#pragma omp target parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
94  for (int k = 0; k < argc; ++k)
95    ++k;
96#pragma omp target parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
97  for (int k = 0; k < argc; ++k)
98    ++k;
99#pragma omp target parallel for simd firstprivate(argc) allocate(omp_thread_mem_alloc: argc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel for simd' directive}}
100  for (int k = 0; k < argc; ++k)
101    ++k;
102#pragma omp target parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
103  for (int k = 0; k < argc; ++k)
104    ++k;
105#pragma omp target parallel for simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
106  for (int k = 0; k < argc; ++k)
107    ++k;
108#pragma omp target parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
109  for (int k = 0; k < argc; ++k)
110    ++k;
111#pragma omp target parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
112  for (int k = 0; k < argc; ++k)
113    ++k;
114#pragma omp target parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
115  for (int k = 0; k < argc; ++k)
116    ++k;
117#pragma omp parallel
118  {
119    int v = 0;
120    int i;
121#pragma omp target parallel for simd firstprivate(i)
122    for (int k = 0; k < argc; ++k) {
123      i = k;
124      v += i;
125    }
126  }
127#pragma omp parallel shared(i)
128#pragma omp parallel private(i)
129#pragma omp target parallel for simd firstprivate(j)
130  for (int k = 0; k < argc; ++k)
131    ++k;
132#pragma omp target parallel for simd firstprivate(i)
133  for (int k = 0; k < argc; ++k)
134    ++k;
135#pragma omp target parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
136  for (i = 0; i < argc; ++i)
137    foo();
138#pragma omp parallel private(i)
139#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
140  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
141    foo();
142#pragma omp parallel reduction(+ : i)
143#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
144  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
145    foo();
146  return 0;
147}
148
149namespace A {
150double x;
151#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
152}
153namespace B {
154using A::x;
155}
156
157int main(int argc, char **argv) {
158  const int d = 5;
159  const int da[5] = {0};
160  S4 e(4);
161  S5 g(5);
162  S3 m;
163  S6 n(2);
164  int i;
165  int &j = i;
166#pragma omp target parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
167  for (i = 0; i < argc; ++i)
168    foo();
169#pragma omp target parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170  for (i = 0; i < argc; ++i)
171    foo();
172#pragma omp target parallel for simd firstprivate() // expected-error {{expected expression}}
173  for (i = 0; i < argc; ++i)
174    foo();
175#pragma omp target parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
176  for (i = 0; i < argc; ++i)
177    foo();
178#pragma omp target parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
179  for (i = 0; i < argc; ++i)
180    foo();
181#pragma omp target parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
182  for (i = 0; i < argc; ++i)
183    foo();
184#pragma omp target parallel for simd firstprivate(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 '('}}
185  for (i = 0; i < argc; ++i)
186    foo();
187#pragma omp target parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
188  for (i = 0; i < argc; ++i)
189    foo();
190#pragma omp target parallel for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
191  for (i = 0; i < argc; ++i)
192    foo();
193#pragma omp target parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
194  for (i = 0; i < argc; ++i)
195    foo();
196#pragma omp target parallel for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
197  for (i = 0; i < argc; ++i)
198    foo();
199#pragma omp target parallel for simd firstprivate(ba) // OK
200  for (i = 0; i < argc; ++i)
201    foo();
202#pragma omp target parallel for simd firstprivate(ca) // OK
203  for (i = 0; i < argc; ++i)
204    foo();
205#pragma omp target parallel for simd firstprivate(da) // OK
206  for (i = 0; i < argc; ++i)
207    foo();
208  int xa;
209#pragma omp target parallel for simd firstprivate(xa) // OK
210  for (i = 0; i < argc; ++i)
211    foo();
212#pragma omp target parallel for simd firstprivate(S2::S2s) // OK
213  for (i = 0; i < argc; ++i)
214    foo();
215#pragma omp target parallel for simd firstprivate(S2::S2sc) // OK
216  for (i = 0; i < argc; ++i)
217    foo();
218#pragma omp target parallel for simd safelen(5) // OK
219  for (i = 0; i < argc; ++i)
220    foo();
221#pragma omp target parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
222  for (i = 0; i < argc; ++i)
223    foo();
224#pragma omp target parallel for simd firstprivate(m) // OK
225  for (i = 0; i < argc; ++i)
226    foo();
227#pragma omp target parallel for simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
228  for (i = 0; i < argc; ++i)
229    foo();
230#pragma omp target parallel for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
231  for (i = 0; i < argc; ++i)
232    foo();
233#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
234  for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
235    foo();
236#pragma omp parallel shared(xa)
237#pragma omp target parallel for simd firstprivate(xa) // OK: may be firstprivate
238  for (i = 0; i < argc; ++i)
239    foo();
240#pragma omp target parallel for simd firstprivate(j)
241  for (i = 0; i < argc; ++i)
242    foo();
243#pragma omp target parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
244  for (i = 0; i < argc; ++i)
245    foo();
246#pragma omp target parallel for simd lastprivate(n) firstprivate(n) // OK
247  for (i = 0; i < argc; ++i)
248    foo();
249#pragma omp parallel
250  {
251    int v = 0;
252    int i;
253#pragma omp target parallel for simd firstprivate(i)
254    for (int k = 0; k < argc; ++k) {
255      i = k;
256      v += i;
257    }
258  }
259#pragma omp parallel private(i)
260#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
261  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
262    foo();
263#pragma omp parallel reduction(+ : i)
264#pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
265  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
266    foo();
267  static int si;
268#pragma omp target parallel for simd firstprivate(si) // OK
269  for (i = 0; i < argc; ++i)
270    si = i + 1;
271
272  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
273}
274