[AST/Sema] Add @extensible attribute on enum declarations

This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.

(cherry picked from commit a0ae93d3a8)
This commit is contained in:
Pavel Yaskevich
2025-04-03 09:54:14 -07:00
parent 49dbb15f5f
commit bcf38a1aef
14 changed files with 98 additions and 22 deletions

View File

@@ -876,6 +876,11 @@ SIMPLE_DECL_ATTR(constInitialized, ConstInitialized,
168)
DECL_ATTR_FEATURE_REQUIREMENT(ConstInitialized, CompileTimeValues)
SIMPLE_DECL_ATTR(extensible, Extensible,
OnEnum,
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
169)
SIMPLE_DECL_ATTR(concurrent, Concurrent,
OnFunc | OnConstructor | OnSubscript | OnVar,
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,

View File

@@ -8711,6 +8711,19 @@ GROUPED_WARNING(
"behavior",
(StringRef))
//===----------------------------------------------------------------------===//
// MARK: @extensible Attribute
//===----------------------------------------------------------------------===//
ERROR(extensible_attr_on_frozen_type,none,
"cannot use '@extensible' together with '@frozen'", ())
ERROR(extensible_attr_on_internal_type,none,
"'@extensible' attribute can only be applied to public or package "
"declarations, but %0 is "
"%select{private|fileprivate|internal|%error|%error|%error}1",
(DeclName, AccessLevel))
//===----------------------------------------------------------------------===//
// MARK: `using` declaration
//===----------------------------------------------------------------------===//