[clang] [HLSL] Add testing for space parameter on global constants (PR #106782)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 12:32:01 PDT 2024


================
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
+
+
+// expected-error at +1 {{invalid space specifier 's2' used; expected 'space' followed by an integer, like space1}}
+cbuffer a : register(b0, s2) {
+
+}
+
+// expected-error at +1 {{invalid space specifier 'spaces' used; expected 'space' followed by an integer, like space1}}
+cbuffer b : register(b2, spaces) {
+
+}
+
+// expected-error at +1 {{wrong argument format for hlsl attribute, use space3 instead}}
+cbuffer c : register(b2, space 3) {}
+
+// expected-error at +1 {{register space cannot be specified on global constants}}
+int d : register(c2, space3);
+
+struct S {
+    RWBuffer<int> a;
+};
+
+// expected-error at +1 {{register space cannot be specified on global constants}}
+S thing : register(u2, space2);
----------------
damyanp wrote:

Ah, interesting - I wouldn't have expected this to be an error.

This is valid:

```
RWBuffer<int> a : register(u2, space2);
```

And I don't think this is really all that different from:

```
S thing : register(u2, space2);
```

But I see DXC rejects it as well. I'm not sure it'd be worth spending any time making clang behave differently here though.



https://github.com/llvm/llvm-project/pull/106782


More information about the cfe-commits mailing list