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.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 04d5b7a75..2a5b5a4e3 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2392,6 +2392,18 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
{
getSink()->diagnose(varDecl, Diagnostics::varCannotBeUnsized);
}
+
+ bool isOpaque = (((int)varTypeTags & (int)TypeTag::Opaque) != 0);
+ if (isOpaque && isGlobalDecl(varDecl) && !varDecl->hasModifier<ConstModifier>() &&
+ varDecl->hasModifier<HLSLStaticModifier>())
+ {
+ // Opaque type global variable must be const.
+ getSink()->diagnose(varDecl, Diagnostics::globalVarCannotHaveOpaqueType);
+ if (varDecl->initExpr)
+ getSink()->diagnose(varDecl, Diagnostics::doYouMeanStaticConst);
+ else
+ getSink()->diagnose(varDecl, Diagnostics::doYouMeanUniform);
+ }
}
if (auto elementType = getConstantBufferElementType(varDecl->getType()))