xref: /llvm-project/clang/test/SemaHIP/amdgpu-buffer-rsrc.hip (revision ad599211a79dd7817f110241372075d82c0ae52a)
1// REQUIRES: amdgpu-registered-target
2// RUN: %clang_cc1 -fsyntax-only -verify -triple amdgcn -Wno-unused-value %s
3// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64 -aux-triple amdgcn -Wno-unused-value %s
4
5#define __device__ __attribute__((device))
6
7__device__ void foo() {
8  int n = 100;
9  __amdgpu_buffer_rsrc_t v = 0; // expected-error {{cannot initialize a variable of type '__amdgpu_buffer_rsrc_t' with an rvalue of type 'int'}}
10  static_cast<__amdgpu_buffer_rsrc_t>(n); // expected-error {{static_cast from 'int' to '__amdgpu_buffer_rsrc_t' is not allowed}}
11  dynamic_cast<__amdgpu_buffer_rsrc_t>(n); // expected-error {{invalid target type '__amdgpu_buffer_rsrc_t' for dynamic_cast; target type must be a reference or pointer type to a defined class}}
12  reinterpret_cast<__amdgpu_buffer_rsrc_t>(n); // expected-error {{reinterpret_cast from 'int' to '__amdgpu_buffer_rsrc_t' is not allowed}}
13  int c(v); // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type '__amdgpu_buffer_rsrc_t'}}
14  __amdgpu_buffer_rsrc_t k;
15  int *ip = (int *)k; // expected-error {{cannot cast from type '__amdgpu_buffer_rsrc_t' to pointer type 'int *'}}
16  void *vp = (void *)k; // expected-error {{cannot cast from type '__amdgpu_buffer_rsrc_t' to pointer type 'void *'}}
17}
18
19static_assert(sizeof(__amdgpu_buffer_rsrc_t) == 16, "wrong size");
20static_assert(alignof(__amdgpu_buffer_rsrc_t) == 16, "wrong aignment");
21