1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized
2
3 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
4
5 struct B {
6 static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
bfooB7 static constexpr int bfoo() { return 8; }
8 };
9 namespace X {
10 B x; // expected-note {{'x' defined here}}
11 };
bfoo()12 constexpr int bfoo() { return 4; }
13
14 int **z;
15 const int C1 = 1;
16 const int C2 = 2;
test_aligned_colons(int * & rp)17 void test_aligned_colons(int *&rp)
18 {
19 int *B = 0;
20
21 #pragma omp target
22 #pragma omp teams distribute simd aligned(B:bfoo())
23 for (int i = 0; i < 10; ++i) ;
24
25 #pragma omp target
26 #pragma omp teams distribute simd aligned(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
27 for (int i = 0; i < 10; ++i) ;
28
29 #pragma omp target
30 #pragma omp teams distribute simd aligned(B:B::bfoo())
31 for (int i = 0; i < 10; ++i) ;
32
33 #pragma omp target
34 #pragma omp teams distribute simd aligned(z:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
35 for (int i = 0; i < 10; ++i) ;
36
37 #pragma omp target
38 #pragma omp teams distribute simd aligned(B:B::bfoo())
39 for (int i = 0; i < 10; ++i) ;
40
41 #pragma omp target
42 #pragma omp teams distribute 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) ;
44
45 #pragma omp target
46 #pragma omp teams distribute 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) ;
48
49 #pragma omp target
50 #pragma omp teams distribute simd aligned(::z)
51 for (int i = 0; i < 10; ++i) ;
52
53 #pragma omp target
54 #pragma omp teams distribute simd aligned(B::bfoo()) // expected-error {{expected variable name}}
55 for (int i = 0; i < 10; ++i) ;
56
57 #pragma omp target
58 #pragma omp teams distribute 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) ;
60 }
61
62 // expected-note@+1 {{'num' defined here}}
test_template(T * arr,N num)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.
68
69 #pragma omp target
70 #pragma omp teams distribute 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;
75 }
76
77 #pragma omp target
78 #pragma omp teams distribute 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);
80
81 return T();
82 }
83
test_warn()84 template<int LEN> int test_warn() {
85 int *ind2 = 0;
86 #pragma omp target
87 #pragma omp teams distribute 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;
90 }
91 return 0;
92 }
93
94 struct S1; // expected-note 2 {{declared here}}
95 extern S1 a; // expected-note {{'a' declared here}}
96 class S2 {
97 mutable int a;
98 public:
S2()99 S2():a(0) { }
100 };
101 const S2 b; // expected-note 1 {{'b' defined here}}
102 const S2 ba[5];
103 class S3 {
104 int a;
105 public:
S3()106 S3():a(0) { }
107 };
108 const S3 ca[5];
109 class S4 {
110 int a;
111 S4();
112 public:
S4(int v)113 S4(int v):a(v) { }
114 };
115 class S5 {
116 int a;
S5()117 S5():a(0) {}
118 public:
S5(int v)119 S5(int v):a(v) { }
120 };
121
122 S3 h; // expected-note 2 {{'h' defined here}}
123 #pragma omp threadprivate(h)
124
foomain(I argc,C ** argv)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;
131
132 #pragma omp target
133 #pragma omp teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}}
134 for (I k = 0; k < argc; ++k) ++k;
135
136 #pragma omp target
137 #pragma omp teams distribute simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
138 for (I k = 0; k < argc; ++k) ++k;
139
140 #pragma omp target
141 #pragma omp teams distribute simd aligned () // expected-error {{expected expression}}
142 for (I k = 0; k < argc; ++k) ++k;
143
144 #pragma omp target
145 #pragma omp teams distribute simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
146 for (I k = 0; k < argc; ++k) ++k;
147
148 #pragma omp target
149 #pragma omp teams distribute simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
150 for (I k = 0; k < argc; ++k) ++k;
151
152 // FIXME: Should argc really be a pointer?
153 #pragma omp target
154 #pragma omp teams distribute simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
155 for (I k = 0; k < argc; ++k) ++k;
156
157 #pragma omp target
158 #pragma omp teams distribute 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;
160
161 #pragma omp target
162 #pragma omp teams distribute simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
163 for (I k = 0; k < argc; ++k) ++k;
164
165 #pragma omp target
166 #pragma omp teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}}
167 for (I k = 0; k < argc; ++k) ++k;
168
169 #pragma omp target
170 #pragma omp teams distribute simd aligned(e, g)
171 for (I k = 0; k < argc; ++k) ++k;
172
173 #pragma omp target
174 #pragma omp teams distribute 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;
176
177 #pragma omp target
178 #pragma omp teams distribute 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;
180
181 #pragma omp parallel
182 {
183 int *v = 0;
184 I i;
185 #pragma omp target
186 #pragma omp teams distribute simd aligned(v:16)
187 for (I k = 0; k < argc; ++k) { i = k; v += 2; }
188 }
189 float *f;
190
191 #pragma omp target
192 #pragma omp teams distribute simd aligned(f)
193 for (I k = 0; k < argc; ++k) ++k;
194
195 int v = 0;
196
197 #pragma omp target
198 #pragma omp teams distribute simd aligned(f:j) // expected-note {{initializer of 'j' is not a constant expression}} expected-error {{integral constant expression}}
199
200 for (I k = 0; k < argc; ++k) { ++k; v += j; }
201
202 #pragma omp target
203 #pragma omp teams distribute simd aligned(f)
204 for (I k = 0; k < argc; ++k) ++k;
205
206 return 0;
207 }
208
209 // expected-note@+1 2 {{'argc' defined here}}
main(int argc,char ** argv)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>();
217
218 int i;
219 int &j = i;
220
221 #pragma omp target
222 #pragma omp teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}}
223 for (int k = 0; k < argc; ++k) ++k;
224
225 #pragma omp target
226 #pragma omp teams distribute simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
227 for (int k = 0; k < argc; ++k) ++k;
228
229 #pragma omp target
230 #pragma omp teams distribute simd aligned () // expected-error {{expected expression}}
231 for (int k = 0; k < argc; ++k) ++k;
232
233 #pragma omp target
234 #pragma omp teams distribute simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
235 for (int k = 0; k < argc; ++k) ++k;
236
237 #pragma omp target
238 #pragma omp teams distribute 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;
240
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;
245
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;
250
251 #pragma omp target
252 #pragma omp teams distribute simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
253 for (int k = 0; k < argc; ++k) ++k;
254
255 #pragma omp target
256 #pragma omp teams distribute 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;
258
259 #pragma omp target
260 #pragma omp teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}}
261 for (int k = 0; k < argc; ++k) ++k;
262
263 #pragma omp target
264 #pragma omp teams distribute 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;
266
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;
271 }
272
273