summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-decl.cpp18
-rw-r--r--source/slang/slang-check-impl.h1
-rw-r--r--source/slang/slang-diagnostic-defs.h5
3 files changed, 24 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,
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index 94c595321..d08cae66f 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -2264,6 +2264,7 @@ public:
void maybeInferArraySizeForVariable(VarDeclBase* varDecl);
void validateArraySizeForVariable(VarDeclBase* varDecl);
+ void validateArrayElementTypeForVariable(VarDeclBase* varDecl);
IntVal* getIntVal(IntegerLiteralExpr* expr);
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 6f0a6274e..8ec910f15 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -650,6 +650,11 @@ DIAGNOSTIC(
"Cannot convert array of size $0 to array of size $1 as this would truncate data")
DIAGNOSTIC(30025, Error, invalidArraySize, "array size must be non-negative.")
DIAGNOSTIC(
+ 30027,
+ Error,
+ disallowedArrayOfParameterBlock,
+ "Arrays of ParameterBlock are not allowed")
+DIAGNOSTIC(
30029,
Error,
arrayIndexOutOfBounds,