| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify |
| 2 |
|
| 3 |
// valid |
| 4 |
cbuffer cbuf { |
| 5 |
RWBuffer<int> r : register(u0, space0); |
| 6 |
} |
| 7 |
|
| 8 |
cbuffer cbuf2 { |
| 9 |
struct x { |
| 10 |
// this test validates that no diagnostic is emitted on the space parameter, because |
| 11 |
// this register annotation is not in the global scope. |
| 12 |
// expected-error@+1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}} |
| 13 |
RWBuffer<int> E : register(u2, space3); |
| 14 |
}; |
| 15 |
} |
| 16 |
|
| 17 |
struct MyStruct { |
| 18 |
RWBuffer<int> E; |
| 19 |
}; |
| 20 |
|
| 21 |
cbuffer cbuf3 { |
| 22 |
// valid |
| 23 |
MyStruct E : register(u2, space3); |
| 24 |
} |
| 25 |
|
| 26 |
// valid |
| 27 |
MyStruct F : register(u3, space4); |
| 28 |
|
| 29 |
cbuffer cbuf4 { |
| 30 |
// this test validates that no diagnostic is emitted on the space parameter, because |
| 31 |
// this register annotation is not in the global scope. |
| 32 |
// expected-error@+1 {{binding type 'u' only applies to UAV resources}} |
| 33 |
float a : register(u2, space3); |
| 34 |
} |
| 35 |
|
| 36 |
// expected-error@+1 {{invalid space specifier 's2' used; expected 'space' followed by an integer, like space1}} |
| 37 |
cbuffer a : register(b0, s2) { |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
// expected-error@+1 {{invalid space specifier 'spaces' used; expected 'space' followed by an integer, like space1}} |
| 42 |
cbuffer b : register(b2, spaces) { |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
// expected-error@+1 {{wrong argument format for hlsl attribute, use space3 instead}} |
| 47 |
cbuffer c : register(b2, space 3) {} |
| 48 |
|
| 49 |
// expected-error@+1 {{register space cannot be specified on global constants}} |
| 50 |
int d : register(c2, space3); |
| 51 |
|
| 52 |
// expected-error@+1 {{register space cannot be specified on global constants}} |
| 53 |
int e : register(c2, space0); |
| 54 |
|
| 55 |
// expected-error@+1 {{register space cannot be specified on global constants}} |
| 56 |
int f : register(c2, space00); |
| 57 |
|
| 58 |
// valid |
| 59 |
RWBuffer<int> g : register(u2, space0); |
| 60 |
|
| 61 |
// valid |
| 62 |
RWBuffer<int> h : register(u2, space0); |