[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_simd_aligned_messages.cpp
blob5c331e34382a11544375fe32e5a025b9abf54835
1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
5 struct B {
6 static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
7 static constexpr int bfoo() { return 8; }
8 };
9 namespace X {
10 B x; // expected-note {{'x' defined here}}
12 constexpr int bfoo() { return 4; }
14 int **z;
15 const int C1 = 1;
16 const int C2 = 2;
17 void test_aligned_colons(int *&rp)
19 int *B = 0;
21 #pragma omp target
22 #pragma omp teams distribute parallel for simd aligned(B:bfoo())
23 for (int i = 0; i < 10; ++i) ;
25 #pragma omp target
26 #pragma omp teams distribute parallel for simd aligned(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
27 for (int i = 0; i < 10; ++i) ;
29 #pragma omp target
30 #pragma omp teams distribute parallel for simd aligned(B:B::bfoo())
31 for (int i = 0; i < 10; ++i) ;
33 #pragma omp target
34 #pragma omp teams distribute parallel for simd aligned(z:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
35 for (int i = 0; i < 10; ++i) ;
37 #pragma omp target
38 #pragma omp teams distribute parallel for simd aligned(B:B::bfoo())
39 for (int i = 0; i < 10; ++i) ;
41 #pragma omp target
42 #pragma omp teams distribute parallel for simd aligned(X::x : ::z) // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
43 for (int i = 0; i < 10; ++i) ;
45 #pragma omp target
46 #pragma omp teams distribute parallel for simd aligned(B,rp,::z: X::x) // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
47 for (int i = 0; i < 10; ++i) ;
49 #pragma omp target
50 #pragma omp teams distribute parallel for simd aligned(::z)
51 for (int i = 0; i < 10; ++i) ;
53 #pragma omp target
54 #pragma omp teams distribute parallel for simd aligned(B::bfoo()) // expected-error {{expected variable name}}
55 for (int i = 0; i < 10; ++i) ;
57 #pragma omp target
58 #pragma omp teams distribute parallel for simd aligned(B::ib,B:C1+C2) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
59 for (int i = 0; i < 10; ++i) ;
62 // expected-note@+1 {{'num' defined here}}
63 template<int L, class T, class N> T test_template(T* arr, N num) {
64 N i;
65 T sum = (T)0;
66 T ind2 = - num * L;
67 // Negative number is passed as L.
69 #pragma omp target
70 #pragma omp teams distribute parallel for simd aligned(arr:L) // expected-error {{argument to 'aligned' clause must be a strictly positive integer value}}
71 for (i = 0; i < num; ++i) {
72 T cur = arr[(int)ind2];
73 ind2 += L;
74 sum += cur;
77 #pragma omp target
78 #pragma omp teams distribute parallel for simd aligned(num:4) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
79 for (i = 0; i < num; ++i);
81 return T();
84 template<int LEN> int test_warn() {
85 int *ind2 = 0;
86 #pragma omp target
87 #pragma omp teams distribute parallel for simd aligned(ind2:LEN) // expected-error {{argument to 'aligned' clause must be a strictly positive integer value}}
88 for (int i = 0; i < 100; i++) {
89 ind2 += LEN;
91 return 0;
94 struct S1; // expected-note 2 {{declared here}} // expected-note {{forward declaration of 'S1'}}
95 extern S1 a; // expected-note {{'a' declared here}}
96 class S2 {
97 mutable int a;
98 public:
99 S2():a(0) { }
101 const S2 b; // expected-note 1 {{'b' defined here}}
102 const S2 ba[5];
103 class S3 {
104 int a;
105 public:
106 S3():a(0) { }
108 const S3 ca[5];
109 class S4 {
110 int a;
111 S4();
112 public:
113 S4(int v):a(v) { }
115 class S5 {
116 int a;
117 S5():a(0) {}
118 public:
119 S5(int v):a(v) { }
122 S3 h; // expected-note 2 {{'h' defined here}}
123 #pragma omp threadprivate(h)
125 template<class I, class C> int foomain(I argc, C **argv) {
126 I e(argc);
127 I g(argc);
128 int i; // expected-note {{'i' defined here}}
129 // expected-note@+1 {{declared here}}
130 int &j = i;
132 #pragma omp target
133 #pragma omp teams distribute parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
134 for (I k = 0; k < argc; ++k) ++k;
136 #pragma omp target
137 #pragma omp teams distribute parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
138 for (I k = 0; k < argc; ++k) ++k;
140 #pragma omp target
141 #pragma omp teams distribute parallel for simd aligned () // expected-error {{expected expression}}
142 for (I k = 0; k < argc; ++k) ++k;
144 #pragma omp target
145 #pragma omp teams distribute parallel for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
146 for (I k = 0; k < argc; ++k) ++k;
148 #pragma omp target
149 #pragma omp teams distribute parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
150 for (I k = 0; k < argc; ++k) ++k;
152 // FIXME: Should argc really be a pointer?
153 #pragma omp target
154 #pragma omp teams distribute parallel for simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
155 for (I k = 0; k < argc; ++k) ++k;
157 #pragma omp target
158 #pragma omp teams distribute parallel for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
159 for (I k = 0; k < argc; ++k) ++k;
161 #pragma omp target
162 #pragma omp teams distribute parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
163 for (I k = 0; k < argc; ++k) ++k;
165 #pragma omp target
166 #pragma omp teams distribute parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
167 for (I k = 0; k < argc; ++k) ++k;
169 #pragma omp target
170 #pragma omp teams distribute parallel for simd aligned(e, g)
171 for (I k = 0; k < argc; ++k) ++k;
173 #pragma omp target
174 #pragma omp teams distribute parallel for simd aligned(h) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
175 for (I k = 0; k < argc; ++k) ++k;
177 #pragma omp target
178 #pragma omp teams distribute parallel for simd aligned(i) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
179 for (I k = 0; k < argc; ++k) ++k;
181 #pragma omp parallel
183 int *v = 0;
184 I i;
185 #pragma omp target
186 #pragma omp teams distribute parallel for simd aligned(v:16)
187 for (I k = 0; k < argc; ++k) { i = k; v += 2; }
189 float *f;
191 #pragma omp target
192 #pragma omp teams distribute parallel for simd aligned(f)
193 for (I k = 0; k < argc; ++k) ++k;
195 int v = 0;
197 #pragma omp target
198 #pragma omp teams distribute parallel for simd aligned(f:j) // expected-note {{initializer of 'j' is not a constant expression}} expected-error {{integral constant expression}}
200 for (I k = 0; k < argc; ++k) { ++k; v += j; }
202 #pragma omp target
203 #pragma omp teams distribute parallel for simd aligned(f)
204 for (I k = 0; k < argc; ++k) ++k;
206 return 0;
209 // expected-note@+1 2 {{'argc' defined here}}
210 int main(int argc, char **argv) {
211 double darr[100];
212 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
213 test_template<-4>(darr, 4);
214 test_warn<4>(); // ok
215 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
216 test_warn<0>();
218 int i;
219 int &j = i;
221 #pragma omp target
222 #pragma omp teams distribute parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
223 for (int k = 0; k < argc; ++k) ++k;
225 #pragma omp target
226 #pragma omp teams distribute parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
227 for (int k = 0; k < argc; ++k) ++k;
229 #pragma omp target
230 #pragma omp teams distribute parallel for simd aligned () // expected-error {{expected expression}}
231 for (int k = 0; k < argc; ++k) ++k;
233 #pragma omp target
234 #pragma omp teams distribute parallel for simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
235 for (int k = 0; k < argc; ++k) ++k;
237 #pragma omp target
238 #pragma omp teams distribute parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
239 for (int k = 0; k < argc; ++k) ++k;
241 #pragma omp target
242 #pragma omp teams
243 #pragma omp distribute simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
244 for (int k = 0; k < argc; ++k) ++k;
246 #pragma omp target
247 #pragma omp teams
248 #pragma omp distribute simd aligned (argc) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
249 for (int k = 0; k < argc; ++k) ++k;
251 #pragma omp target
252 #pragma omp teams distribute parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
253 for (int k = 0; k < argc; ++k) ++k;
255 #pragma omp target
256 #pragma omp teams distribute parallel for simd aligned (a, b) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}} expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}}
257 for (int k = 0; k < argc; ++k) ++k;
259 #pragma omp target
260 #pragma omp teams distribute parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
261 for (int k = 0; k < argc; ++k) ++k;
263 #pragma omp target
264 #pragma omp teams distribute parallel for simd aligned(h) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
265 for (int k = 0; k < argc; ++k) ++k;
267 int *pargc = &argc;
268 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
269 foomain<int*,char>(pargc,argv);
270 return 0;