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.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 4bfbde584..867c1daad 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -10241,6 +10241,17 @@ void SemanticsDeclHeaderVisitor::checkInterfaceRequirement(Decl* decl)
}
}
+bool doesTypeHaveNoDiffModifier(Type* type)
+{
+ if (auto modifiedType = as<ModifiedType>(type))
+ {
+ if (modifiedType->findModifier<NoDiffModifierVal>() != nullptr)
+ return true;
+ return doesTypeHaveNoDiffModifier(modifiedType->getBase());
+ }
+ return false;
+}
+
void SemanticsDeclHeaderVisitor::checkCallableDeclCommon(CallableDecl* decl)
{
for (auto paramDecl : decl->getParameters())
@@ -10259,6 +10270,13 @@ void SemanticsDeclHeaderVisitor::checkCallableDeclCommon(CallableDecl* decl)
}
decl->errorType = errorType;
+ if (doesTypeHaveNoDiffModifier(decl->returnType.type))
+ {
+ auto noDiffMod = m_astBuilder->create<NoDiffModifier>();
+ noDiffMod->loc = decl->loc;
+ addModifier(decl, noDiffMod);
+ }
+
checkDifferentiableCallableCommon(decl);
// If this method is intended to be a CUDA kernel, verify that the return type is void.