mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Prevent use of @extensible without ExtensibleAttribute feature
This commit is contained in:
@@ -880,6 +880,7 @@ SIMPLE_DECL_ATTR(extensible, Extensible,
|
||||
OnEnum,
|
||||
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
|
||||
169)
|
||||
DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute)
|
||||
|
||||
SIMPLE_DECL_ATTR(concurrent, Concurrent,
|
||||
OnFunc | OnConstructor | OnSubscript | OnVar,
|
||||
|
||||
@@ -330,7 +330,6 @@ struct _S {
|
||||
// ON_MEMBER_LAST-DAG: Keyword/None: freestanding[#Declaration Attribute#]; name=freestanding
|
||||
// ON_MEMBER_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions
|
||||
// ON_MEMBER_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime
|
||||
// ON_MEMBER_LAST-DAG: Keyword/None: extensible[#Declaration Attribute#]; name=extensible
|
||||
// ON_MEMBER_LAST-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
|
||||
// ON_MEMBER_LAST-NOT: Keyword
|
||||
// ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
||||
@@ -404,7 +403,6 @@ func dummy2() {}
|
||||
// KEYWORD_LAST-DAG: Keyword/None: attached[#Declaration Attribute#]; name=attached
|
||||
// KEYWORD_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions
|
||||
// KEYWORD_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime
|
||||
// KEYWORD_LAST-DAG: Keyword/None: extensible[#Declaration Attribute#]; name=extensible
|
||||
// KEYWORD_LAST-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
|
||||
// KEYWORD_LAST-NOT: Keyword
|
||||
// KEYWORD_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
// RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED
|
||||
// RUN: %batch-code-completion -filecheck-additional-suffix _ENABLED \
|
||||
// RUN: -enable-experimental-feature ABIAttribute
|
||||
// RUN: -enable-experimental-feature ABIAttribute \
|
||||
// RUN: -enable-experimental-feature ExtensibleAttribute
|
||||
|
||||
// NOTE: Please do not include the ", N items" after "Begin completions". The
|
||||
// item count creates needless merge conflicts given that an "End completions"
|
||||
@@ -34,6 +35,8 @@
|
||||
// KEYWORD4: Begin completions
|
||||
// KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
|
||||
// KEYWORD4_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
|
||||
// KEYWORD4_ENABLED-DAG: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible
|
||||
// KEYWORD4_DISABLED-NOT: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible
|
||||
// KEYWORD4: End completions
|
||||
|
||||
@#^KEYWORD5^# struct S{}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
/// Build the library
|
||||
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
||||
// RUN: -module-name Lib \
|
||||
// RUN: -emit-module-path %t/Lib.swiftmodule
|
||||
// RUN: -emit-module-path %t/Lib.swiftmodule \
|
||||
// RUN: -enable-experimental-feature ExtensibleAttribute
|
||||
|
||||
// Check that the errors are produced when using enums from module with `ExtensibleEnums` feature enabled.
|
||||
// RUN: %target-swift-frontend -typecheck %t/src/TestChecking.swift \
|
||||
@@ -18,7 +19,9 @@
|
||||
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
||||
// RUN: -module-name Lib \
|
||||
// RUN: -package-name Test \
|
||||
// RUN: -emit-module-path %t/Lib.swiftmodule
|
||||
// RUN: -emit-module-path %t/Lib.swiftmodule \
|
||||
// RUN: -enable-experimental-feature ExtensibleAttribute
|
||||
|
||||
|
||||
// Different module but the same package
|
||||
// RUN: %target-swift-frontend -typecheck %t/src/TestSamePackage.swift \
|
||||
@@ -26,6 +29,8 @@
|
||||
// RUN: -package-name Test \
|
||||
// RUN: -verify
|
||||
|
||||
// REQUIRES: swift_feature_ExtensibleAttribute
|
||||
|
||||
//--- Lib.swift
|
||||
|
||||
@extensible
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ExtensibleAttribute
|
||||
|
||||
// REQUIRES: swift_feature_ExtensibleAttribute
|
||||
|
||||
@extensible
|
||||
public enum E1 { // Ok
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-typecheck-verify-swift -parse-as-library -disable-experimental-parser-round-trip -verify-additional-prefix disabled-
|
||||
// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature ABIAttribute
|
||||
// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature ABIAttribute -enable-experimental-feature ExtensibleAttribute
|
||||
|
||||
// REQUIRES: asserts
|
||||
|
||||
@@ -14,3 +14,13 @@ func fn() {} // expected-disabled-error@-1 {{'abi' attribute is only valid when
|
||||
#else
|
||||
#error("doesn't have @abi") // expected-disabled-error {{doesn't have @abi}}
|
||||
#endif
|
||||
|
||||
@extensible
|
||||
public enum E {} // expected-disabled-error@-1 {{'extensible' attribute is only valid when experimental feature ExtensibleAttribute is enabled}}
|
||||
|
||||
#if hasAttribute(extensible)
|
||||
#error("does have @extensible") // expected-enabled-error {{does have @extensible}}
|
||||
#else
|
||||
#error("doesn't have @extensible") // expected-disabled-error {{doesn't have @extensible}}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user