diff options
| author | Yong He <yonghe@outlook.com> | 2022-12-01 18:55:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-01 18:55:43 -0800 |
| commit | e7df8538eb8f0ed06f0838d946bec8e9e0fe0985 (patch) | |
| tree | 3c08e646600ab82ffda260f2b6deb96dd2085776 /source/slang/slang-check-expr.cpp | |
| parent | f51f69d045d9e0b83d9ab1f4623d4319ce1867be (diff) | |
Allow `no_diff` on `this` parameter. (#2543)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 7297ca282..336682bf4 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -503,7 +503,11 @@ namespace Slang auto toBeSynthesized = m_astBuilder->create<ToBeSynthesizedModifier>(); addModifier(synthesizedDecl, toBeSynthesized); - return ConstructDeclRefExpr(makeDeclRef(synthesizedDecl), nullptr, originalExpr->loc, originalExpr); + return ConstructDeclRefExpr( + makeDeclRef(synthesizedDecl), + nullptr, + originalExpr ? originalExpr->loc : SourceLoc(), + originalExpr); } Expr* SemanticsVisitor::ConstructLookupResultExpr( @@ -1927,6 +1931,10 @@ namespace Slang { getSink()->diagnose(forwardDiff, Diagnostics::functionNotMarkedAsDifferentiable, funcDecl, "backward"); } + if (!isEffectivelyStatic(funcDecl) && !isGlobalDecl(funcDecl)) + { + getSink()->diagnose(forwardDiff, Diagnostics::nonStaticMemberFunctionNotAllowedAsDiffOperand, funcDecl); + } } } } |
