|  | 
|  | 1 | +// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s | 
|  | 2 | + | 
|  | 3 | +typedef vector<float, 3> float3; | 
|  | 4 | +typedef vector<double, 2> double2; | 
|  | 5 | +typedef vector<double, 3> double3; | 
|  | 6 | + | 
|  | 7 | + | 
|  | 8 | +// expected-error@+1 {{class template 'Buffer' requires template arguments}} | 
|  | 9 | +Buffer BufferErr1; | 
|  | 10 | + | 
|  | 11 | +// expected-error@+1 {{too few template arguments for class template 'Buffer'}} | 
|  | 12 | +Buffer<> BufferErr2; | 
|  | 13 | + | 
|  | 14 | +// test implicit Buffer concept | 
|  | 15 | +Buffer<int> r1; | 
|  | 16 | +Buffer<float> r2; | 
|  | 17 | +Buffer<float3> Buff; | 
|  | 18 | +Buffer<double2> r4; | 
|  | 19 | + | 
|  | 20 | +// expected-error@+4 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 21 | +// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class Buffer}} | 
|  | 22 | +// expected-note@*:* {{because 'hlsl::Buffer<int>' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 23 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(hlsl::Buffer<int>)' evaluated to false}} | 
|  | 24 | +Buffer<Buffer<int> > r5; | 
|  | 25 | + | 
|  | 26 | +struct s { | 
|  | 27 | +    int x; | 
|  | 28 | +}; | 
|  | 29 | + | 
|  | 30 | +struct Empty {}; | 
|  | 31 | + | 
|  | 32 | +template<typename T> struct TemplatedBuffer { | 
|  | 33 | +    T a; | 
|  | 34 | +}; | 
|  | 35 | + | 
|  | 36 | +template<typename T> struct TemplatedVector { | 
|  | 37 | +    vector<T, 4> v; | 
|  | 38 | +}; | 
|  | 39 | + | 
|  | 40 | +// structs not allowed | 
|  | 41 | +// expected-error@+4 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 42 | +// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class Buffer}} | 
|  | 43 | +// expected-note@*:* {{because 's' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 44 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(s)' evaluated to false}} | 
|  | 45 | +Buffer<s> r6; | 
|  | 46 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 47 | +// expected-note@*:* {{because 'Empty' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 48 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(Empty)' evaluated to false}} | 
|  | 49 | +Buffer<Empty> r7; | 
|  | 50 | + | 
|  | 51 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 52 | +// expected-note@*:* {{because 'TemplatedBuffer<int>' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 53 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(TemplatedBuffer<int>)' evaluated to false}} | 
|  | 54 | +Buffer<TemplatedBuffer<int> > r8; | 
|  | 55 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 56 | +// expected-note@*:* {{because 'TemplatedVector<int>' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 57 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(TemplatedVector<int>)' evaluated to false}} | 
|  | 58 | +Buffer<TemplatedVector<int> > r9; | 
|  | 59 | + | 
|  | 60 | +// arrays not allowed | 
|  | 61 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 62 | +// expected-note@*:* {{because 'half[4]' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 63 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(half[4])' evaluated to false}} | 
|  | 64 | +Buffer<half[4]> r10; | 
|  | 65 | + | 
|  | 66 | +typedef vector<int, 8> int8; | 
|  | 67 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 68 | +// expected-note@*:* {{because 'vector<int, 8>' (vector of 8 'int' values) does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 69 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(vector<int, 8>)' evaluated to false}} | 
|  | 70 | +Buffer<int8> r11; | 
|  | 71 | + | 
|  | 72 | +typedef int MyInt; | 
|  | 73 | +Buffer<MyInt> r12; | 
|  | 74 | + | 
|  | 75 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 76 | +// expected-note@*:* {{because 'bool' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 77 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(bool)' evaluated to false}} | 
|  | 78 | +Buffer<bool> r13; | 
|  | 79 | + | 
|  | 80 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 81 | +// expected-note@*:* {{because 'vector<bool, 2>' (vector of 2 'bool' values) does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 82 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(vector<bool, 2>)' evaluated to false}} | 
|  | 83 | +Buffer<vector<bool, 2>> r14; | 
|  | 84 | + | 
|  | 85 | +enum numbers { one, two, three }; | 
|  | 86 | + | 
|  | 87 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 88 | +// expected-note@*:* {{because 'numbers' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 89 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(numbers)' evaluated to false}} | 
|  | 90 | +Buffer<numbers> r15; | 
|  | 91 | + | 
|  | 92 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 93 | +// expected-note@*:* {{because 'vector<double, 3>' (vector of 3 'double' values) does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 94 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(vector<double, 3>)' evaluated to false}} | 
|  | 95 | +Buffer<double3> r16; | 
|  | 96 | + | 
|  | 97 | + | 
|  | 98 | +struct threeDoubles { | 
|  | 99 | +  double a; | 
|  | 100 | +  double b; | 
|  | 101 | +  double c; | 
|  | 102 | +}; | 
|  | 103 | + | 
|  | 104 | +// expected-error@+3 {{constraints not satisfied for class template 'Buffer'}} | 
|  | 105 | +// expected-note@*:* {{because 'threeDoubles' does not satisfy '__is_typed_resource_element_compatible'}} | 
|  | 106 | +// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(threeDoubles)' evaluated to false}} | 
|  | 107 | +Buffer<threeDoubles> BufferErr3; | 
|  | 108 | + | 
|  | 109 | + | 
|  | 110 | +[numthreads(1,1,1)] | 
|  | 111 | +void main() { | 
|  | 112 | +  (void)Buff.__handle; // expected-error {{'__handle' is a private member of 'hlsl::Buffer<vector<float, 3>>'}} | 
|  | 113 | +  // expected-note@* {{implicitly declared private here}} | 
|  | 114 | +} | 
0 commit comments