summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp21
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(