| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify |
| 2 |
|
| 3 |
template<typename T> |
| 4 |
struct MyTemplatedSRV { |
| 5 |
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x; |
| 6 |
}; |
| 7 |
|
| 8 |
// valid, The register keyword in this statement isn't binding a resource, rather it is |
| 9 |
// specifying a constant register binding offset within the $Globals cbuffer, which is legacy behavior from DX9. |
| 10 |
float a : register(c0); |
| 11 |
|
| 12 |
// expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}} |
| 13 |
cbuffer b : register(i0) { |
| 14 |
|
| 15 |
} |
| 16 |
|
| 17 |
// expected-error@+1 {{register number should be an integer}} |
| 18 |
cbuffer c : register(bf, s2) { |
| 19 |
|
| 20 |
} |
| 21 |
|
| 22 |
// expected-error@+1 {{expected identifier}} |
| 23 |
cbuffer A : register() {} |
| 24 |
|
| 25 |
// expected-error@+1 {{invalid space specifier 'space' used; expected 'space' followed by an integer, like space1}} |
| 26 |
cbuffer B : register(space) {} |
| 27 |
|
| 28 |
// expected-error@+1 {{wrong argument format for hlsl attribute, use b2 instead}} |
| 29 |
cbuffer C : register(b 2) {} |
| 30 |
|
| 31 |
// expected-error@+1 {{wrong argument format for hlsl attribute, use b2 instead}} |
| 32 |
cbuffer D : register(b 2, space3) {} |
| 33 |
|
| 34 |
// expected-error@+1 {{expected <numeric_constant>}} |
| 35 |
cbuffer E : register(u-1) {}; |
| 36 |
|
| 37 |
// expected-error@+1 {{expected <numeric_constant>}} |
| 38 |
cbuffer F : register(u) {}; |
| 39 |
|
| 40 |
// expected-error@+1 {{binding type 'u' only applies to UAV resources}} |
| 41 |
cbuffer G : register(u13) {}; |
| 42 |
|
| 43 |
// expected-error@+1 {{binding type 'c' only applies to numeric variables in the global scope}} |
| 44 |
cbuffer H : register(c0) {}; |
| 45 |
|
| 46 |
// expected-error@+1 {{binding type 't' only applies to SRV resources}} |
| 47 |
cbuffer I : register(t0) {} |
| 48 |
|
| 49 |
// expected-error@+1 {{binding type 'b' only applies to constant buffer resources}} |
| 50 |
tbuffer J : register(b0) {}; |
| 51 |
|
| 52 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 53 |
static MyTemplatedSRV<float> U : register(u5); |
| 54 |
|
| 55 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 56 |
static float sa : register(c1); |
| 57 |
|
| 58 |
float x[2] : register(c2); // valid |
| 59 |
float y[2][2] : register(c3); // valid |
| 60 |
float z[2][2][3] : register(c4); // valid |
| 61 |
|
| 62 |
// expected-error@+1 {{binding type 'c' only applies to numeric variables in the global scope}} |
| 63 |
groupshared float fa[10] : register(c5); |
| 64 |
|
| 65 |
void foo() { |
| 66 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 67 |
MyTemplatedSRV<float> U : register(u3); |
| 68 |
} |
| 69 |
void foo2() { |
| 70 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 71 |
extern MyTemplatedSRV<float> U2 : register(u5); |
| 72 |
} |
| 73 |
|
| 74 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 75 |
void bar(MyTemplatedSRV<float> U : register(u3)) { |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
struct S { |
| 80 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 81 |
MyTemplatedSRV<float> U : register(u3); |
| 82 |
}; |
| 83 |
|
| 84 |
// expected-error@+1 {{binding type 'z' is invalid}} |
| 85 |
MyTemplatedSRV<float> U3 : register(z5); |