summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2025-08-08 20:15:25 +0800
committerGitHub <noreply@github.com>2025-08-08 12:15:25 +0000
commit5d1ba37be64980d80e5106f8664a654d907ebaf4 (patch)
tree039933a1e1a902478b3902f6c350745590ca2a80 /source/slang/slang-check-decl.cpp
parentc7c4816146bb9ec055e9a8f8c3f975624f2fdb07 (diff)
Diagnose on array of parameterblock instead of asserting (#8123)
Closes https://github.com/shader-slang/slang/issues/5750
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index d6bc50b82..72b5c19db 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2187,6 +2187,10 @@ void SemanticsDeclHeaderVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
// arrays in specific cases)
//
validateArraySizeForVariable(varDecl);
+ //
+ // Similarly, we want to check the element type for any restrictions
+ //
+ validateArrayElementTypeForVariable(varDecl);
}
// If there is a matrix layout modifier or texture format modifier, we will modify the type now.
@@ -10745,6 +10749,20 @@ void SemanticsVisitor::validateArraySizeForVariable(VarDeclBase* varDecl)
}
}
+void SemanticsVisitor::validateArrayElementTypeForVariable(VarDeclBase* varDecl)
+{
+ auto arrayType = as<ArrayExpressionType>(varDecl->type);
+ if (!arrayType)
+ return;
+
+ const auto elementType = arrayType->getElementType();
+ if (as<ParameterBlockType>(elementType))
+ {
+ getSink()->diagnose(varDecl, Diagnostics::disallowedArrayOfParameterBlock);
+ return;
+ }
+}
+
bool getExtensionTargetDeclList(
ASTBuilder* astBuilder,
DeclRefType* targetDeclRefType,