[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_parallel_for_simd_aligned_messages.cpp
blobc635663431f6c5a58be62e93ed09ab1f0f2d53ce
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;
20 #pragma omp target parallel for simd aligned(B:bfoo())
21 for (int i = 0; i < 10; ++i) ;
22 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
23 #pragma omp target parallel for simd aligned(B::ib:B:bfoo())
24 for (int i = 0; i < 10; ++i) ;
25 #pragma omp target parallel for simd aligned(B:B::bfoo())
26 for (int i = 0; i < 10; ++i) ;
27 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
28 #pragma omp target parallel for simd aligned(z:B:bfoo())
29 for (int i = 0; i < 10; ++i) ;
30 #pragma omp target parallel for simd aligned(B:B::bfoo())
31 for (int i = 0; i < 10; ++i) ;
32 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
33 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
34 #pragma omp target parallel for simd aligned(X::x : ::z)
35 for (int i = 0; i < 10; ++i) ;
36 // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
37 #pragma omp target parallel for simd aligned(B,rp,::z: X::x)
38 for (int i = 0; i < 10; ++i) ;
39 #pragma omp target parallel for simd aligned(::z)
40 for (int i = 0; i < 10; ++i) ;
41 // expected-error@+1 {{expected variable name}}
42 #pragma omp target parallel for simd aligned(B::bfoo())
43 for (int i = 0; i < 10; ++i) ;
44 // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
45 #pragma omp target parallel for simd aligned(B::ib,B:C1+C2)
46 for (int i = 0; i < 10; ++i) ;
49 // expected-note@+1 {{'num' defined here}}
50 template<int L, class T, class N> T test_template(T* arr, N num) {
51 N i;
52 T sum = (T)0;
53 T ind2 = - num * L;
54 // Negative number is passed as L.
55 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
56 #pragma omp target parallel for simd aligned(arr:L)
57 for (i = 0; i < num; ++i) {
58 T cur = arr[(int)ind2];
59 ind2 += L;
60 sum += cur;
62 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
63 #pragma omp target parallel for simd aligned(num:4)
64 for (i = 0; i < num; ++i);
65 return T();
68 template<int LEN> int test_warn() {
69 int *ind2 = 0;
70 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
71 #pragma omp target parallel for simd aligned(ind2:LEN)
72 for (int i = 0; i < 100; i++) {
73 ind2 += LEN;
75 return 0;
78 struct S1; // expected-note 2 {{declared here}}
79 extern S1 a; // expected-note {{'a' declared here}}
80 class S2 {
81 mutable int a;
82 public:
83 S2():a(0) { }
85 const S2 b; // expected-note 1 {{'b' defined here}}
86 const S2 ba[5];
87 class S3 {
88 int a;
89 public:
90 S3():a(0) { }
92 const S3 ca[5];
93 class S4 {
94 int a;
95 S4();
96 public:
97 S4(int v):a(v) { }
99 class S5 {
100 int a;
101 S5():a(0) {}
102 public:
103 S5(int v):a(v) { }
106 S3 h; // expected-note 2 {{'h' defined here}}
107 #pragma omp threadprivate(h)
109 template<class I, class C> int foomain(I argc, C **argv) {
110 I e(argc);
111 I g(argc);
112 int i; // expected-note {{'i' defined here}}
113 // expected-note@+1 {{declared here}}
114 int &j = i;
115 #pragma omp target parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
116 for (I k = 0; k < argc; ++k) ++k;
117 #pragma omp target parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
118 for (I k = 0; k < argc; ++k) ++k;
119 #pragma omp target parallel for simd aligned () // expected-error {{expected expression}}
120 for (I k = 0; k < argc; ++k) ++k;
121 #pragma omp target parallel for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (I k = 0; k < argc; ++k) ++k;
123 #pragma omp target parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
124 for (I k = 0; k < argc; ++k) ++k;
125 // FIXME: Should argc really be a pointer?
126 #pragma omp target parallel for simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
127 for (I k = 0; k < argc; ++k) ++k;
128 #pragma omp target parallel for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
129 for (I k = 0; k < argc; ++k) ++k;
130 #pragma omp target parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
131 for (I k = 0; k < argc; ++k) ++k;
132 #pragma omp target parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
133 for (I k = 0; k < argc; ++k) ++k;
134 #pragma omp target parallel for simd aligned(e, g)
135 for (I k = 0; k < argc; ++k) ++k;
136 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
137 #pragma omp target parallel for simd aligned(h)
138 for (I k = 0; k < argc; ++k) ++k;
139 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
140 #pragma omp target parallel for simd aligned(i)
141 for (I k = 0; k < argc; ++k) ++k;
142 #pragma omp parallel
144 int *v = 0;
145 I i;
146 #pragma omp target parallel for simd aligned(v:16)
147 for (I k = 0; k < argc; ++k) { i = k; v += 2; }
149 float *f;
150 #pragma omp target parallel for simd aligned(f)
151 for (I k = 0; k < argc; ++k) ++k;
152 int v = 0;
153 // expected-note@+2 {{initializer of 'j' is not a constant expression}}
154 // expected-error@+1 {{integral constant expression}}
155 #pragma omp target parallel for simd aligned(f:j)
156 for (I k = 0; k < argc; ++k) { ++k; v += j; }
157 #pragma omp target parallel for simd aligned(f)
158 for (I k = 0; k < argc; ++k) ++k;
159 return 0;
162 // expected-note@+1 2 {{'argc' defined here}}
163 int main(int argc, char **argv) {
164 double darr[100];
165 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
166 test_template<-4>(darr, 4);
167 test_warn<4>(); // ok
168 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
169 test_warn<0>();
171 int i;
172 int &j = i;
173 #pragma omp target parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
174 for (int k = 0; k < argc; ++k) ++k;
175 #pragma omp target parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
176 for (int k = 0; k < argc; ++k) ++k;
177 #pragma omp target parallel for simd aligned () // expected-error {{expected expression}}
178 for (int k = 0; k < argc; ++k) ++k;
179 #pragma omp target parallel for simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
180 for (int k = 0; k < argc; ++k) ++k;
181 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
182 #pragma omp target parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
183 for (int k = 0; k < argc; ++k) ++k;
184 #pragma omp target parallel for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
185 for (int k = 0; k < argc; ++k) ++k;
186 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
187 #pragma omp target parallel for simd aligned (argc)
188 for (int k = 0; k < argc; ++k) ++k;
189 #pragma omp target parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
190 for (int k = 0; k < argc; ++k) ++k;
191 // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
192 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
193 #pragma omp target parallel for simd aligned (a, b)
194 for (int k = 0; k < argc; ++k) ++k;
195 #pragma omp target parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
196 for (int k = 0; k < argc; ++k) ++k;
197 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
198 #pragma omp target parallel for simd aligned(h)
199 for (int k = 0; k < argc; ++k) ++k;
200 int *pargc = &argc;
201 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
202 foomain<int*,char>(pargc,argv);
203 return 0;