[clang] [HLSL] Add testing for space parameter on global constants (PR #106782)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 13 09:34:25 PDT 2024
================
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
+
+// valid
+cbuffer cbuf {
+ RWBuffer<int> r : register(u0, space0);
+}
+
+cbuffer cbuf2 {
+ struct x {
+ // expected-error at +1 {{'register' attribute only applies to cbuffer/tbuffer and external global variables}}
+ RWBuffer<int> E : register(u2, space3);
+ };
+}
+
+struct MyStruct {
+ RWBuffer<int> E;
+};
+
+cbuffer cbuf3 {
+ MyStruct E : register(u2, space3);
----------------
bob80905 wrote:
> And I think that we said that this would report a "can't use space on globals" error?
I would argue those 2 cases are not equivalent, because one register annotation is not in the global scope, and the other is. So, the second case would emit an error about the annotation not being in the global scope, and the first would not.
I've explicitly added the second case along with the expected error for clarity.
https://github.com/llvm/llvm-project/pull/106782
More information about the cfe-commits
mailing list