summaryrefslogtreecommitdiff
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.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 875fddf2f..9a4ee9d71 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2040,11 +2040,14 @@ namespace Slang
}
}
- if (auto parentDecl = as<AggTypeDecl>(getParentDecl(varDecl)))
+ TypeTag varTypeTags = getTypeTags(varDecl->getType());
+ auto parentDecl = as<AggTypeDecl>(getParentDecl(varDecl));
+ if (parentDecl)
{
- auto typeTags = getTypeTags(varDecl->getType());
- parentDecl->addTag(typeTags);
- if ((int)typeTags & (int)TypeTag::Unsized)
+ parentDecl->addTag(varTypeTags);
+ auto unsizedMask = (int)TypeTag::Unsized;
+ bool isUnknownSize = (((int)varTypeTags & unsizedMask) != 0);
+ if (isUnknownSize)
{
// Unsized decl must appear as the last member of the struct.
for (auto memberIdx = parentDecl->members.getCount() - 1; memberIdx >= 0; memberIdx--)
@@ -2064,7 +2067,17 @@ namespace Slang
}
}
}
-
+ bool isGlobalOrLocalVar = !isGlobalShaderParameter(varDecl) && !as<ParamDecl>(varDecl) &&
+ (!parentDecl || isEffectivelyStatic(varDecl));
+ if (isGlobalOrLocalVar)
+ {
+ bool isUnsized = (((int)varTypeTags & (int)TypeTag::Unsized) != 0);
+ if (isUnsized)
+ {
+ getSink()->diagnose(varDecl, Diagnostics::varCannotBeUnsized);
+ }
+ }
+
if (auto elementType = getConstantBufferElementType(varDecl->getType()))
{
if (doesTypeHaveTag(elementType, TypeTag::Incomplete))