From 07f21ee31b5f427edb72d5578f713b3da3f3b96f Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:19:25 -0700 Subject: Error if super-type capabilities are a super-set of sub-type (#7452) Fixes: #7410 Changes: 1. super-type capabilities must be a super-set of sub-type capabilities (and support the same shader stages/targets) * InheritanceDecl visits super-type to inherit it's capabilities; validate InheritanceDecl capabilities against sub-type * visit all container decl's with a default case * clean up functionDeclBase visitor * Simplify `diagnoseUndeclaredCapability` by moving logic into capability checking (more correct*) 3. added changed behavior to documentation 4. fixed some incorrect capabilities 5. **we do not** diagnose capability errors on interface requirement-to-implementation if both lack explicit capability requirements. This change is to work around a slangpy regression (test case for the failing situation is in `tests\language-feature\capability\capability-interface-extension-1.slang`), Note: maybe for slang-2026 we don't do this? 6. requirement & implementation must support the same shader stage/target. This was changed because otherwise we can have cases where `X` inherits from `Y`, but `Y` is only expected to be used in `glsl` whilst `X` is expected to be used in `hlsl | glsl` 7. removed `tests/language-feature/capability/capabilitySimplification3.slang` because it tests nothing special (redundant) Note: not using rebase due to separate branches depending on this PR --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang-parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-parser.cpp') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 7e9740b53..1302975df 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -5754,7 +5754,7 @@ static Stmt* parseTargetSwitchStmtImpl(Parser* parser, TargetSwitchStmt* stmt) Diagnostics::unknownTargetName, caseName.getContent()); } - targetCase->capability = int32_t(cap); + targetCase->capability = (int32_t)cap; targetCase->capabilityToken = caseName; targetCase->loc = caseName.loc; targetCase->body = bodyStmt; @@ -8743,7 +8743,7 @@ Expr* Parser::ParseLeafExpression() /// Parse an argument to an application of a generic static Expr* _parseGenericArg(Parser* parser) { - // The grammar for generic arguments needs to be a super-set of the + // The grammar for generic arguments needs to be a superset of the // grammar for types and for expressions, because we do not know // which to expect at each argument position during parsing. // -- cgit v1.2.3