diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-02 22:28:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-02 22:28:02 -0800 |
| commit | 14764896c34b230a5563f48d8b8e565de2f3aa10 (patch) | |
| tree | 2f105d3f6222103f458054f1cd38e280b6fb52b4 /source/slang/slang-check-stmt.cpp | |
| parent | c15e7ade4e27e1649d5b98f5854e9e52bb9e60ae (diff) | |
Capability type checking. (#3530)
* Capability type checking.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-stmt.cpp')
| -rw-r--r-- | source/slang/slang-check-stmt.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp index b2c58ccc7..1090655e5 100644 --- a/source/slang/slang-check-stmt.cpp +++ b/source/slang/slang-check-stmt.cpp @@ -52,7 +52,7 @@ namespace Slang // local `struct` declaration, where it would have members // that need to be recursively checked. // - ensureDeclBase(stmt->decl, DeclCheckState::Checked, this); + ensureDeclBase(stmt->decl, DeclCheckState::DefinitionChecked, this); } void SemanticsStmtVisitor::visitBlockStmt(BlockStmt* stmt) @@ -207,7 +207,7 @@ namespace Slang stmt->varDecl->type.type = m_astBuilder->getIntType(); addModifier(stmt->varDecl, m_astBuilder->create<ConstModifier>()); - stmt->varDecl->setCheckState(DeclCheckState::Checked); + stmt->varDecl->setCheckState(DeclCheckState::DefinitionChecked); IntVal* rangeBeginVal = nullptr; IntVal* rangeEndVal = nullptr; @@ -280,7 +280,20 @@ namespace Slang void SemanticsStmtVisitor::visitTargetCaseStmt(TargetCaseStmt* stmt) { auto switchStmt = FindOuterStmt<TargetSwitchStmt>(); + CapabilitySet set((CapabilityName)stmt->capability); + if (getShared()->isInLanguageServer() && getShared()->getSession()->getCompletionRequestTokenName() == stmt->capabilityToken.getName()) + { + getShared()->getLinkage()->contentAssistInfo.completionSuggestions.scopeKind = CompletionSuggestions::ScopeKind::Capabilities; + } + if (stmt->capabilityToken.getContentLength() != 0 && + (set.getExpandedAtoms().getCount() != 1 || set.isInvalid() || set.isEmpty())) + { + getSink()->diagnose( + stmt->capabilityToken.loc, + Diagnostics::invalidTargetSwitchCase, + capabilityNameToString((CapabilityName)stmt->capability)); + } if (!switchStmt) { getSink()->diagnose(stmt, Diagnostics::caseOutsideSwitch); @@ -648,7 +661,7 @@ namespace Slang { stmt->device = CheckExpr(stmt->device); stmt->gridDims = CheckExpr(stmt->gridDims); - ensureDeclBase(stmt->dispatchThreadID, DeclCheckState::Checked, this); + ensureDeclBase(stmt->dispatchThreadID, DeclCheckState::DefinitionChecked, this); WithOuterStmt subContext(this, stmt); stmt->kernelCall = subContext.CheckExpr(stmt->kernelCall); return; |
