From 96df31a9fa53e3d897a2b7c4eef021f37f421c91 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Mon, 13 Oct 2025 23:14:45 +0900 Subject: 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 --- .../array-of-struct-with-parameterblock.slang | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/diagnostics/array-of-struct-with-parameterblock.slang (limited to 'tests/diagnostics/array-of-struct-with-parameterblock.slang') diff --git a/tests/diagnostics/array-of-struct-with-parameterblock.slang b/tests/diagnostics/array-of-struct-with-parameterblock.slang new file mode 100644 index 000000000..07ca3a50f --- /dev/null +++ b/tests/diagnostics/array-of-struct-with-parameterblock.slang @@ -0,0 +1,44 @@ +// Test that arrays of structs containing ParameterBlocks are properly diagnosed +// with error 30027 instead of causing a compiler crash + +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// A struct that contains a ParameterBlock member +struct MyStruct +{ + ParameterBlock pb; + int data; +} + +interface IMyInterface +{ + int getValue(); +} + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + // CHECK: ([[# @LINE+1]]): error 30027: + MyStruct arr[2]; + + // Also test with dynamic arrays + // CHECK: ([[# @LINE+1]]): error 30027: + MyStruct dynamicArr[]; +} + +// Test nested structs as well +struct OuterStruct +{ + MyStruct inner; + float value; +} + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain2() +{ + // Nested struct containing ParameterBlock should also trigger the error + // CHECK: ([[# @LINE+1]]): error 30027: + OuterStruct nestedArr[3]; +} -- cgit v1.2.3