46 lines · c
1// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3
4void foo(void) {}
5
6typedef struct {
7 int len;
8 double data[12];
9} S;
10
11int main(int argc, char **argv) {
12 int len = 12;
13 double data1[len], data2[len];
14 S s;
15
16 // Valid multiple strided array sections
17 #pragma omp target update from(data1[0:4:2], data2[0:2:5]) // OK
18 {}
19
20 #pragma omp target update to(data1[1:2:3], data2[2:3:2]) // OK
21 {}
22
23 // Mixed strided and regular array sections
24 #pragma omp target update from(data1[0:len], data2[0:4:2]) // OK
25 {}
26
27 // Struct member arrays with strides
28 #pragma omp target update from(s.data[0:4:2]) // OK
29 {}
30
31 #pragma omp target update from(s.data[0:s.len/2:2]) // OK
32 {}
33
34 // Invalid stride in one of multiple sections
35 #pragma omp target update from(data1[0:3:4], data2[0:2:0]) // expected-error {{section stride is evaluated to a non-positive value 0}}
36
37 // Complex expressions in multiple arrays
38 int stride1 = 2, stride2 = 3;
39 #pragma omp target update from(data1[0:len/2:stride1], data2[1:len/3:stride2]) // OK
40 {}
41
42 // Missing colon
43 #pragma omp target update from(data1[0:4:2], data2[0:3 4]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
44
45 return 0;
46}