diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-17 13:23:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-17 13:23:27 -0800 |
| commit | 051607368e8d3dd55d2ad2b2200ef656244ec70d (patch) | |
| tree | c1a6ce8d7551e5a74e36349d43ee4c05ae6ed21c /source/slang/slang-check-decl.cpp | |
| parent | 79049bc7617be0d20f6ed5d9d1dfe75006aa675a (diff) | |
Fixed crash when lowering IR for no_diff struct member. (#2658)
* Fixed crash when lowering IR for no_diff struct member.
* Improve `setInsertBeforeOrdinaryInst` and `setInsertAfterOrdinaryInst`.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 837dcb8eb..381efa2c7 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -1291,6 +1291,16 @@ namespace Slang { checkExtensionExternVarAttribute(varDecl, extensionExternAttr); } + + // If a var decl has no_diff type, move the no_diff modifier from the type to the var. + if (auto modifiedType = as<ModifiedType>(varDecl->type.type)) + { + if (auto nodiffModifier = modifiedType->findModifier<NoDiffModifierVal>()) + { + varDecl->type.type = getRemovedModifierType(modifiedType, nodiffModifier); + addModifier(varDecl, m_astBuilder->getOrCreate<NoDiffModifier>()); + } + } } void SemanticsDeclHeaderVisitor::visitStructDecl(StructDecl* structDecl) @@ -1527,6 +1537,8 @@ namespace Slang // Go through all var members. for (auto member : context->parentDecl->getMembersOfType<VarDeclBase>()) { + if (member->hasModifier<NoDiffModifier>()) + continue; auto diffType = tryGetDifferentialType(m_astBuilder, member->type.type); if (!diffType) continue; |
