| 1 |
// RUN: %clang_cc1 -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 'RWBuffer' requires template arguments}} |
| 9 |
RWBuffer BufferErr1; |
| 10 |
|
| 11 |
// expected-error@+1 {{too few template arguments for class template 'RWBuffer'}} |
| 12 |
RWBuffer<> BufferErr2; |
| 13 |
|
| 14 |
// test implicit RWBuffer concept |
| 15 |
RWBuffer<int> r1; |
| 16 |
RWBuffer<float> r2; |
| 17 |
RWBuffer<float3> Buff; |
| 18 |
RWBuffer<double2> r4; |
| 19 |
|
| 20 |
// expected-error@+4 {{constraints not satisfied for class template 'RWBuffer'}} |
| 21 |
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class RWBuffer}} |
| 22 |
// expected-note@*:* {{because 'RWBuffer<int>' does not satisfy '__is_typed_resource_element_compatible'}} |
| 23 |
// expected-note@*:* {{because '__builtin_hlsl_is_typed_resource_element_compatible(hlsl::RWBuffer<int>)' evaluated to false}} |
| 24 |
RWBuffer<RWBuffer<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 'RWBuffer'}} |
| 42 |
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class RWBuffer}} |
| 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 |
RWBuffer<s> r6; |
| 46 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<Empty> r7; |
| 50 |
|
| 51 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<TemplatedBuffer<int> > r8; |
| 55 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<TemplatedVector<int> > r9; |
| 59 |
|
| 60 |
// arrays not allowed |
| 61 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<half[4]> r10; |
| 65 |
|
| 66 |
typedef vector<int, 8> int8; |
| 67 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 68 |
// expected-note@*:* {{because 'int8' (aka 'vector<int, 8>') 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 |
RWBuffer<int8> r11; |
| 71 |
|
| 72 |
typedef int MyInt; |
| 73 |
RWBuffer<MyInt> r12; |
| 74 |
|
| 75 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<bool> r13; |
| 79 |
|
| 80 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<vector<bool, 2>> r14; |
| 84 |
|
| 85 |
enum numbers { one, two, three }; |
| 86 |
|
| 87 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 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 |
RWBuffer<numbers> r15; |
| 91 |
|
| 92 |
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}} |
| 93 |
// expected-note@*:* {{because 'double3' (aka 'vector<double, 3>') 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 |
RWBuffer<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 'RWBuffer'}} |
| 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 |
RWBuffer<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::RWBuffer<vector<float, 3>>'}} |
| 113 |
// expected-note@* {{implicitly declared private here}} |
| 114 |
} |