diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2025-10-13 23:14:45 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-13 22:14:45 +0800 |
| commit | 96df31a9fa53e3d897a2b7c4eef021f37f421c91 (patch) | |
| tree | 46cfb983265ce63b619da3b18004d2c163371d2c /source/slang/slang-check-decl.cpp | |
| parent | f5a3a6dc6a98d22964154f809f9e0dcae30ab67f (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 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 867c1daad..1ba8c62f3 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2703,6 +2703,9 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl) { DiagnoseIsAllowedInitExpr(varDecl, getSink()); + // Check for arrays of non-addressable types + validateArrayElementTypeForVariable(varDecl); + // if zero initialize is true, set everything to a default if (getOptionSet().hasOption(CompilerOptionName::ZeroInitialize) && !varDecl->initExpr && as<VarDecl>(varDecl)) @@ -2840,6 +2843,7 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl) } TypeTag varTypeTags = getTypeTags(varDecl->getType()); + auto parentDecl = as<AggTypeDecl>(getParentDecl(varDecl)); if (parentDecl) { @@ -10389,9 +10393,12 @@ void SemanticsVisitor::validateArrayElementTypeForVariable(VarDeclBase* varDecl) return; const auto elementType = arrayType->getElementType(); - if (as<ParameterBlockType>(elementType)) + + // Check if the element type has the NonAddressable tag + TypeTag elementTags = getTypeTags(elementType); + if ((int)elementTags & (int)TypeTag::NonAddressable) { - getSink()->diagnose(varDecl, Diagnostics::disallowedArrayOfParameterBlock); + getSink()->diagnose(varDecl, Diagnostics::disallowedArrayOfNonAddressableType, elementType); return; } } @@ -14738,6 +14745,16 @@ void validateStructuredBufferElementType(SemanticsVisitor* visitor, VarDeclBase* Diagnostics::recursiveTypesFoundInStructuredBuffer, elementType); } + + // Check if the element type is NonAddressable + TypeTag elementTags = visitor->getTypeTags(elementType); + if ((int)elementTags & (int)TypeTag::NonAddressable) + { + visitor->getSink()->diagnose( + varDecl->loc, + Diagnostics::nonAddressableTypeInStructuredBuffer, + elementType); + } } void diagnoseMissingCapabilityProvenance( |
