summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/unbounded-array-nonaddressable.slang
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2025-10-13 23:14:45 +0900
committerGitHub <noreply@github.com>2025-10-13 22:14:45 +0800
commit96df31a9fa53e3d897a2b7c4eef021f37f421c91 (patch)
tree46cfb983265ce63b619da3b18004d2c163371d2c /tests/diagnostics/unbounded-array-nonaddressable.slang
parentf5a3a6dc6a98d22964154f809f9e0dcae30ab67f (diff)
Fix segfault on arrays of structs containing parameter blocks (#8555)
Closes https://github.com/shader-slang/slang/issues/8154 However there is further design work to do on implementing the "NonAddressableType" suggestion
Diffstat (limited to 'tests/diagnostics/unbounded-array-nonaddressable.slang')
-rw-r--r--tests/diagnostics/unbounded-array-nonaddressable.slang46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/diagnostics/unbounded-array-nonaddressable.slang b/tests/diagnostics/unbounded-array-nonaddressable.slang
new file mode 100644
index 000000000..19a870594
--- /dev/null
+++ b/tests/diagnostics/unbounded-array-nonaddressable.slang
@@ -0,0 +1,46 @@
+// Test that unbounded arrays are NonAddressable and cannot be used in arrays
+
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -allow-glsl -stage compute -entry computeMain
+
+// Unbounded array itself is fine
+int unboundedArray[];
+
+// Array of unbounded arrays - should error (unbounded arrays are NonAddressable)
+//CHECK: ([[# @LINE+1]]): error 30027
+int arrayOfUnbounded[3][];
+
+// Struct containing unbounded array (must be last member)
+struct StructWithUnbounded
+{
+ float value;
+ int data[]; // Unbounded array must be last member
+}
+
+// Array of struct containing unbounded array - should error (struct is NonAddressable)
+//CHECK: ([[# @LINE+1]]): error 30027
+StructWithUnbounded myArray[2];
+
+// StructuredBuffer of struct with unbounded array - should error
+//CHECK: ([[# @LINE+1]]): error 30028
+StructuredBuffer<StructWithUnbounded> myBuffer;
+
+// Nested case
+struct NestedUnbounded
+{
+ int id;
+ StructWithUnbounded nested; // Struct with unbounded array member
+}
+
+// Array of nested struct - should error
+//CHECK: ([[# @LINE+1]]): error 30027
+NestedUnbounded nestedArray[5];
+
+// StructuredBuffer of nested struct - should error
+//CHECK: ([[# @LINE+1]]): error 30028
+StructuredBuffer<NestedUnbounded> nestedBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ // Empty - we're just testing the declarations
+} \ No newline at end of file