1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s 2 3typedef vector<float, 3> float3; 4 5StructuredBuffer<float3> Buffer; 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 {}}} 9StructuredBuffer 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 {}}} 13StructuredBuffer<> 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}} 19StructuredBuffer<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. 23struct Empty {}; 24StructuredBuffer<Empty> BufferErr4; 25 26 27[numthreads(1,1,1)] 28void main() { 29 (void)Buffer.__handle; // expected-error {{'__handle' is a private member of 'hlsl::StructuredBuffer<vector<float, 3>>'}} 30 // expected-note@* {{implicitly declared private here}} 31} 32