1 // PowerPC supports VLAs.
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
5 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm-bc %s -o %t-ppc-host-ppc.bc
6 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host-ppc.bc -o %t-ppc-device.ll
8 // Nvidia GPUs don't support VLAs.
9 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
10 // RUN: %clang_cc1 -verify -DNO_VLA -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host-nvptx.bc -o %t-nvptx-device.ll
12 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvptx.bc
15 // expected-no-diagnostics
18 #pragma omp declare target
19 void declare(int arg
) {
22 // expected-error@+2 {{variable length arrays are not supported for the current target}}
27 void declare_parallel_reduction(int arg
) {
30 #pragma omp parallel reduction(+: a)
33 #pragma omp parallel reduction(+: a[0:2])
37 // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}}
38 // expected-note@+2 {{variable length arrays are not supported for the current target}}
40 #pragma omp parallel reduction(+: a[0:arg])
43 #pragma omp end declare target
46 void target_template(int arg
) {
50 // expected-error@+2 {{variable length arrays are not supported for the current target}}
56 void target(int arg
) {
60 // expected-error@+2 {{variable length arrays are not supported for the current target}}
70 // expected-error@+2 {{variable length arrays are not supported for the current target}}
77 // expected-note@+2 {{in instantiation of function template specialization 'target_template<long>' requested here}}
79 target_template
<long>(arg
);
82 void teams_reduction(int arg
) {
86 #pragma omp target map(a)
87 #pragma omp teams reduction(+: a)
91 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
92 // expected-note@+3 {{variable length arrays are not supported for the current target}}
94 #pragma omp target map(vla)
95 #pragma omp teams reduction(+: vla)
98 #pragma omp target map(a[0:2])
99 #pragma omp teams reduction(+: a[0:2])
102 #pragma omp target map(vla[0:2])
103 #pragma omp teams reduction(+: vla[0:2])
107 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
108 // expected-note@+3 {{variable length arrays are not supported for the current target}}
110 #pragma omp target map(a[0:arg])
111 #pragma omp teams reduction(+: a[0:arg])
115 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
116 // expected-note@+3 {{variable length arrays are not supported for the current target}}
118 #pragma omp target map(vla[0:arg])
119 #pragma omp teams reduction(+: vla[0:arg])
123 void parallel_reduction(int arg
) {
127 #pragma omp target map(a)
128 #pragma omp parallel reduction(+: a)
132 // expected-error@+4 {{cannot generate code for reduction on variable length array}}
133 // expected-note@+3 {{variable length arrays are not supported for the current target}}
135 #pragma omp target map(vla)
136 #pragma omp parallel reduction(+: vla)
139 #pragma omp target map(a[0:2])
140 #pragma omp parallel reduction(+: a[0:2])
143 #pragma omp target map(vla[0:2])
144 #pragma omp parallel reduction(+: vla[0:2])
148 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
149 // expected-note@+3 {{variable length arrays are not supported for the current target}}
151 #pragma omp target map(a[0:arg])
152 #pragma omp parallel reduction(+: a[0:arg])
156 // expected-error@+4 {{cannot generate code for reduction on array section, which requires a variable length array}}
157 // expected-note@+3 {{variable length arrays are not supported for the current target}}
159 #pragma omp target map(vla[0:arg])
160 #pragma omp parallel reduction(+: vla[0:arg])
164 void for_reduction(int arg
) {
168 #pragma omp target map(a)
170 #pragma omp for reduction(+: a)
171 for (int i
= 0; i
< arg
; i
++) ;
174 // expected-error@+5 {{cannot generate code for reduction on variable length array}}
175 // expected-note@+4 {{variable length arrays are not supported for the current target}}
177 #pragma omp target map(vla)
179 #pragma omp for reduction(+: vla)
180 for (int i
= 0; i
< arg
; i
++) ;
182 #pragma omp target map(a[0:2])
184 #pragma omp for reduction(+: a[0:2])
185 for (int i
= 0; i
< arg
; i
++) ;
187 #pragma omp target map(vla[0:2])
189 #pragma omp for reduction(+: vla[0:2])
190 for (int i
= 0; i
< arg
; i
++) ;
193 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
194 // expected-note@+4 {{variable length arrays are not supported for the current target}}
196 #pragma omp target map(a[0:arg])
198 #pragma omp for reduction(+: a[0:arg])
199 for (int i
= 0; i
< arg
; i
++) ;
202 // expected-error@+5 {{cannot generate code for reduction on array section, which requires a variable length array}}
203 // expected-note@+4 {{variable length arrays are not supported for the current target}}
205 #pragma omp target map(vla[0:arg])
207 #pragma omp for reduction(+: vla[0:arg])
208 for (int i
= 0; i
< arg
; i
++) ;
210 // expected-error@+3 {{cannot generate code for reduction on array section, which requires a variable length array}}
211 // expected-note@+2 {{variable length arrays are not supported for the current target}}
213 #pragma omp target reduction(+ : vla[0:arg])
214 for (int i
= 0; i
< arg
; i
++) ;