diff options
| author | Yong He <yonghe@outlook.com> | 2025-05-29 08:05:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 08:05:57 -0700 |
| commit | faf042ecc3e688a1a3ffbe1ac44d18dd7ddf441a (patch) | |
| tree | b54abb2e65b7791d74335ead396cf762f805ab5c /source/slang/slang-check-decl.cpp | |
| parent | 45d794f57d453a5564a7360400c5bfc04bf12b31 (diff) | |
Language version + tuple syntax. (#7230)
* Language version + tuple syntax.
* Fix compile error.
* regenerate documentation Table of Contents
* Fix.
* regenerate command line reference
* Fix.
* Fix.
* Fix more test failures.
* revert empty line change,
* Retrigger CI
* #version->#lang
* Update source/core/slang-type-text-util.cpp
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
* Remove comments.
* Fix parsing logic.
* Fix parser.
* Fix parser.
* update test comment
* Update options.
* regenerate documentation Table of Contents
* regenerate command line reference
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index f8a80c09b..71aa71e69 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -34,21 +34,18 @@ static bool isAssociatedTypeDecl(Decl* decl) return false; } -static bool isSlang2026(CompilerOptionSet& optionSet) +static bool isSlang2026OrLater(SemanticsVisitor* visitor) { - if (!optionSet.hasOption(CompilerOptionName::Language)) - return false; - return SLANG_SOURCE_LANGUAGE_SLANG == - SlangSourceLanguage( - optionSet.getEnumOption<SlangSourceLanguage>(CompilerOptionName::Language)) && - SLANG_STD_REVISION_2026 == - optionSet.getEnumOption<SlangStdRevision>(CompilerOptionName::StdRevision); + return visitor->getShared()->m_module->getModuleDecl()->languageVersion >= + SLANG_LANGUAGE_VERSION_2026; } -static bool allowExperimentalDynamicDispatch(CompilerOptionSet& optionSet) +static bool allowExperimentalDynamicDispatch( + SemanticsVisitor* visitor, + CompilerOptionSet& optionSet) { return optionSet.getBoolOption(CompilerOptionName::EnableExperimentalDynamicDispatch) || - !isSlang2026(optionSet); + !isSlang2026OrLater(visitor); } static void validateDynInterfaceUsage( @@ -57,7 +54,7 @@ static void validateDynInterfaceUsage( CompilerOptionSet& optionSet, InterfaceDecl* decl) { - if (allowExperimentalDynamicDispatch(optionSet)) + if (allowExperimentalDynamicDispatch(visitor, optionSet)) return; if (!decl->hasModifier<DynModifier>()) @@ -134,7 +131,7 @@ static void validateDynInterfaceUseWithInheritanceDecl( if (!interfaceDeclIsDyn) return; - if (!allowExperimentalDynamicDispatch(optionSet)) + if (!allowExperimentalDynamicDispatch(visitor, optionSet)) { if (auto extensionDeclParent = as<ExtensionDecl>(decl->parentDecl)) { @@ -665,6 +662,13 @@ struct SemanticsDeclReferenceVisitor : public SemanticsDeclVisitorBase, void visitParenExpr(ParenExpr* expr) { dispatchIfNotNull(expr->base); } + void visitTupleExpr(TupleExpr* expr) + { + for (auto element : expr->elements) + dispatchIfNotNull(element); + } + + void visitAssignExpr(AssignExpr* expr) { dispatchIfNotNull(expr->left); @@ -13817,7 +13821,7 @@ void SemanticsDeclCapabilityVisitor::visitInheritanceDecl(InheritanceDecl* inher if (!implDecl) continue; - if (getModuleDecl(implDecl.getDecl())->isInLegacyLanguage) + if (getModuleDecl(implDecl.getDecl())->languageVersion == SLANG_LANGUAGE_VERSION_LEGACY) break; ensureDecl(requirementDecl, DeclCheckState::CapabilityChecked); @@ -13880,8 +13884,9 @@ DeclVisibility getDeclVisibility(Decl* decl) auto defaultVis = DeclVisibility::Default; if (auto parentModule = getModuleDecl(decl)) { - defaultVis = parentModule->isInLegacyLanguage ? DeclVisibility::Public - : parentModule->defaultVisibility; + defaultVis = parentModule->languageVersion == SLANG_LANGUAGE_VERSION_LEGACY + ? DeclVisibility::Public + : parentModule->defaultVisibility; } // Members of other agg type decls will have their default visibility capped to the |
