1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
4 struct MyTemplatedSRV {
5 __hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
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);
12 // expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
13 cbuffer b : register(i0) {
17 // expected-error@+1 {{register number should be an integer}}
18 cbuffer c : register(bf, s2) {
22 // expected-error@+1 {{expected identifier}}
23 cbuffer A : register() {}
25 // expected-error@+1 {{register number should be an integer}}
26 cbuffer B : register(space1) {}
28 // expected-error@+1 {{wrong argument format for hlsl attribute, use b2 instead}}
29 cbuffer C : register(b 2) {}
31 // expected-error@+1 {{wrong argument format for hlsl attribute, use b2 instead}}
32 cbuffer D : register(b 2, space3) {}
34 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
35 static MyTemplatedSRV<float> U : register(u5);
37 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
38 static float sa : register(c1);
40 float x[2] : register(c2); // valid
41 float y[2][2] : register(c3); // valid
42 float z[2][2][3] : register(c4); // valid
44 // expected-error@+1 {{binding type 'c' only applies to numeric variables in the global scope}}
45 groupshared float fa[10] : register(c5);
48 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
49 MyTemplatedSRV<float> U : register(u3);
52 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
53 extern MyTemplatedSRV<float> U2 : register(u5);
56 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
57 void bar(MyTemplatedSRV<float> U : register(u3)) {
62 // expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
63 MyTemplatedSRV<float> U : register(u3);
66 // expected-error@+1 {{binding type 'z' is invalid}}
67 MyTemplatedSRV<float> U3 : register(z5);