summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-01-19 08:58:20 -0800
committerGitHub <noreply@github.com>2023-01-19 08:58:20 -0800
commit6fae15cd1210d8b664243d640e70ca47dccf9752 (patch)
treed3235149f587ed18147f7a0d916932e199dce888 /source/slang/slang-check-expr.cpp
parent0586f3298fa7d554fa2682103eefba88740d6758 (diff)
Add diagnostic for calling non-bwd-diff func from bwd-diff func. (#2602)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 2fc18628e..43124b535 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -1967,6 +1967,10 @@ namespace Slang
if (m_parentDifferentiableAttr)
{
+ FunctionDifferentiableLevel callerDiffLevel = FunctionDifferentiableLevel::None;
+ if (m_parentFunc)
+ callerDiffLevel = getShared()->getFuncDifferentiableLevel(m_parentFunc);
+
if (auto checkedInvokeExpr = as<InvokeExpr>(checkedExpr))
{
// Register types for final resolved invoke arguments again.
@@ -1978,7 +1982,8 @@ namespace Slang
{
if (auto calleeDecl = as<FunctionDeclBase>(calleeExpr->declRef.getDecl()))
{
- if (getShared()->isDifferentiableFunc(calleeDecl))
+ auto calleeDiffLevel = getShared()->getFuncDifferentiableLevel(calleeDecl);
+ if (calleeDiffLevel >= callerDiffLevel)
{
if (!m_treatAsDifferentiableExpr)
{