| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s |
| 2 |
|
| 3 |
typedef vector<float, 3> float3; |
| 4 |
|
| 5 |
StructuredBuffer<float3> Buff; |
| 6 |
|
| 7 |
// expected-error@+2 {{class template 'StructuredBuffer' requires template arguments}} |
| 8 |
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_structured_resource_element_compatible<element_type> class StructuredBuffer {}}} |
| 9 |
StructuredBuffer BufferErr1; |
| 10 |
|
| 11 |
// expected-error@+2 {{too few template arguments for class template 'StructuredBuffer'}} |
| 12 |
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_structured_resource_element_compatible<element_type> class StructuredBuffer {}}} |
| 13 |
StructuredBuffer<> BufferErr2; |
| 14 |
|
| 15 |
// test elements of 0 size |
| 16 |
// expected-error@+3{{constraints not satisfied for class template 'StructuredBuffer' [with element_type = int[0]]}} |
| 17 |
// expected-note@*:*{{because 'int[0]' does not satisfy '__is_structured_resource_element_compatible'}} |
| 18 |
// expected-note@*:*{{because 'sizeof(int[0]) >= 1UL' (0 >= 1) evaluated to false}} |
| 19 |
StructuredBuffer<int[0]> BufferErr3; |
| 20 |
|
| 21 |
// In C++, empty structs do have a size of 1. So should HLSL. |
| 22 |
// The concept will accept empty structs as element types, despite it being unintuitive. |
| 23 |
struct Empty {}; |
| 24 |
StructuredBuffer<Empty> BufferErr4; |
| 25 |
|
| 26 |
|
| 27 |
[numthreads(1,1,1)] |
| 28 |
void main() { |
| 29 |
(void)Buff.__handle; // expected-error {{'__handle' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}} |
| 30 |
// expected-note@* {{implicitly declared private here}} |
| 31 |
|
| 32 |
// expected-error@+2 {{cannot assign to return value because function 'operator[]' returns a const value}} |
| 33 |
// expected-note@* {{function 'operator[]' which returns const-qualified type 'vector<float const hlsl_device &, 3>' declared here}} |
| 34 |
Buff[0] = 0.0; |
| 35 |
} |