summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 2865188b4..ddc4ec4d5 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -7811,7 +7811,7 @@ void SemanticsDeclBasesVisitor::visitStructDecl(StructDecl* decl)
{
getSink()->diagnose(
inheritanceDecl,
- Diagnostics::baseOfStructMustBeStructOrInterface,
+ Diagnostics::baseOfStructMustBeInterface,
decl,
baseType);
continue;
@@ -7823,6 +7823,26 @@ void SemanticsDeclBasesVisitor::visitStructDecl(StructDecl* decl)
}
else if (auto baseStructDeclRef = baseDeclRef.as<StructDecl>())
{
+ if (!isFromCoreModule(decl))
+ {
+ // In Slang 2026, we no longer allow structs to inherit from other structs.
+ if (isSlang2026OrLater(this))
+ {
+ getSink()->diagnose(
+ inheritanceDecl,
+ Diagnostics::baseOfStructMustBeInterface,
+ decl,
+ baseType);
+ }
+ else
+ {
+ // For legacy langauge versions, we still allow struct inheritance to avoid
+ // breaking existing code, but we will emit a warning to inform the user
+ // that this feature is unstable and may be removed in the future.
+ getSink()->diagnose(inheritanceDecl, Diagnostics::inheritanceUnstable);
+ }
+ }
+
// To simplify the task of reading and maintaining code,
// we require that when a `struct` inherits from another
// `struct`, the base `struct` is the first item in
@@ -7845,7 +7865,7 @@ void SemanticsDeclBasesVisitor::visitStructDecl(StructDecl* decl)
{
getSink()->diagnose(
inheritanceDecl,
- Diagnostics::baseOfStructMustBeStructOrInterface,
+ Diagnostics::baseOfStructMustBeInterface,
decl,
baseType);
continue;