Debian Codegraph @

clang/test/SemaHIP/zero-sized-device-array.hip

raw
1 // REQUIRES: amdgpu-registered-target
2 // RUN: %clang_cc1 -fsyntax-only -x hip -fcuda-is-device -verify -triple amdgcn %s
3 #define __device__ __attribute__((device))
4 #define __host__ __attribute__((host))
5 #define __global__ __attribute__((global))
6 #define __shared__ __attribute__((shared))
7
8 typedef float ZEROARR[0];
9
10 float global_array[0];
11
12 __global__ void global_fun() {
13 extern __shared__ float externArray[];
14 ZEROARR TypeDef; // expected-error {{zero-length arrays are not permitted in HIP device code}}
15 float array[0]; // expected-error {{zero-length arrays are not permitted in HIP device code}}
16 }
17
18 // should not throw error for host side code.
19 __host__ void host_fun() {
20 float array[0];
21 }
22
23 template <typename Ty, unsigned Size>
24 __device__ void templated()
25 {
26 Ty arr[Size]; // expected-error {{zero-length arrays are not permitted in HIP device code}}
27 }
28
29 __host__ __device__ void host_dev_fun()
30 {
31 float array[0]; // expected-error {{zero-length arrays are not permitted in HIP device code}}
32 }
33
34 __device__ void device_fun()
35 {
36 __shared__ float array[0]; // expected-error {{zero-length arrays are not permitted in HIP device code}}
37 templated<int,0>(); // expected-note {{in instantiation of function template specialization 'templated<int, 0U>' requested here}}
38 }