| 1 |
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify |
| 2 |
|
| 3 |
// RWStructuredBuffer<int> |
| 4 |
using handle_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]] [[hlsl::raw_buffer]]; |
| 5 |
// RWBuffer<int> |
| 6 |
using bad_handle_not_raw_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]]; |
| 7 |
// RWByteAddressBuffer |
| 8 |
using bad_handle_no_type_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer]]; |
| 9 |
// StructuredBuffer |
| 10 |
using bad_handle_not_uav_t = __hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::contained_type(int)]] [[hlsl::raw_buffer]]; |
| 11 |
|
| 12 |
void test_args(int x, bool b) { |
| 13 |
// expected-error@+1 {{too few arguments to function call, expected 2, have 1}} |
| 14 |
__builtin_hlsl_buffer_update_counter(x); |
| 15 |
|
| 16 |
// expected-error@+1 {{too many arguments to function call, expected 2, have 3}} |
| 17 |
__builtin_hlsl_buffer_update_counter(x, x, x); |
| 18 |
|
| 19 |
// expected-error@+1 {{cannot initialize a parameter of type '__hlsl_resource_t' with an lvalue of type 'int'}} |
| 20 |
__builtin_hlsl_buffer_update_counter(x, x); |
| 21 |
|
| 22 |
bad_handle_not_raw_t bad1; |
| 23 |
bad_handle_no_type_t bad2; |
| 24 |
bad_handle_not_uav_t bad3; |
| 25 |
|
| 26 |
// expected-error@+1 {{invalid __hlsl_resource_t type attributes}} |
| 27 |
__builtin_hlsl_buffer_update_counter(bad1, 1); |
| 28 |
|
| 29 |
// expected-error@+1 {{invalid __hlsl_resource_t type attributes}} |
| 30 |
__builtin_hlsl_buffer_update_counter(bad2, 1); |
| 31 |
|
| 32 |
// expected-error@+1 {{invalid __hlsl_resource_t type attributes}} |
| 33 |
__builtin_hlsl_buffer_update_counter(bad3, 1); |
| 34 |
|
| 35 |
handle_t res; |
| 36 |
|
| 37 |
// expected-error@+1 {{argument 1 must be constant integer 1 or -1}} |
| 38 |
__builtin_hlsl_buffer_update_counter(res, x); |
| 39 |
|
| 40 |
// expected-error@+1 {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char[2]'}} |
| 41 |
__builtin_hlsl_buffer_update_counter(res, "1"); |
| 42 |
|
| 43 |
// expected-error@+1 {{argument 1 must be constant integer 1 or -1}} |
| 44 |
__builtin_hlsl_buffer_update_counter(res, 10); |
| 45 |
|
| 46 |
// no error |
| 47 |
__builtin_hlsl_buffer_update_counter(res, 1); |
| 48 |
} |