49 lines · plain
1// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify2 3// RWStructuredBuffer<int>4using handle_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]] [[hlsl::raw_buffer]];5// RWBuffer<int>6using bad_handle_not_raw_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]];7// RWByteAddressBuffer8using bad_handle_no_type_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer]];9// StructuredBuffer10using bad_handle_not_uav_t = __hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::contained_type(int)]] [[hlsl::raw_buffer]];11 12void 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 error47 __builtin_hlsl_buffer_update_counter(res, 1);48}49