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
(cherry picked from commit 0ad7d8b590)
This commit is contained in:
@@ -880,6 +880,7 @@ SIMPLE_DECL_ATTR(extensible, Extensible,
|
|||||||
OnEnum,
|
OnEnum,
|
||||||
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
|
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr,
|
||||||
169)
|
169)
|
||||||
|
DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute)
|
||||||
|
|
||||||
SIMPLE_DECL_ATTR(concurrent, Concurrent,
|
SIMPLE_DECL_ATTR(concurrent, Concurrent,
|
||||||
OnFunc | OnConstructor | OnSubscript | OnVar,
|
OnFunc | OnConstructor | OnSubscript | OnVar,
|
||||||
|
|||||||
@@ -344,7 +344,6 @@ struct _S {
|
|||||||
// ON_MEMBER_LAST-DAG: Keyword/None: freestanding[#Declaration Attribute#]; name=freestanding
|
// 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: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions
|
||||||
// ON_MEMBER_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime
|
// 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-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
|
||||||
// ON_MEMBER_LAST-NOT: Keyword
|
// ON_MEMBER_LAST-NOT: Keyword
|
||||||
// ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
// ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
||||||
@@ -421,7 +420,6 @@ func dummy2() {}
|
|||||||
// KEYWORD_LAST-DAG: Keyword/None: attached[#Declaration Attribute#]; name=attached
|
// 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: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions
|
||||||
// KEYWORD_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime
|
// 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-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent
|
||||||
// KEYWORD_LAST-NOT: Keyword
|
// KEYWORD_LAST-NOT: Keyword
|
||||||
// KEYWORD_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
// KEYWORD_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
// RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED
|
// RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED
|
||||||
// RUN: %batch-code-completion -filecheck-additional-suffix _ENABLED \
|
// 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
|
// NOTE: Please do not include the ", N items" after "Begin completions". The
|
||||||
// item count creates needless merge conflicts given that an "End completions"
|
// item count creates needless merge conflicts given that an "End completions"
|
||||||
@@ -39,6 +40,8 @@
|
|||||||
// KEYWORD4: Begin completions
|
// KEYWORD4: Begin completions
|
||||||
// KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
|
// KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi
|
||||||
// KEYWORD4_DISABLED-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
|
// KEYWORD4: End completions
|
||||||
|
|
||||||
@#^KEYWORD5^# struct S{}
|
@#^KEYWORD5^# struct S{}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
/// Build the library
|
/// Build the library
|
||||||
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
||||||
// RUN: -module-name Lib \
|
// 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.
|
// Check that the errors are produced when using enums from module with `ExtensibleEnums` feature enabled.
|
||||||
// RUN: %target-swift-frontend -typecheck %t/src/TestChecking.swift \
|
// RUN: %target-swift-frontend -typecheck %t/src/TestChecking.swift \
|
||||||
@@ -18,7 +19,9 @@
|
|||||||
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
// RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \
|
||||||
// RUN: -module-name Lib \
|
// RUN: -module-name Lib \
|
||||||
// RUN: -package-name Test \
|
// 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
|
// Different module but the same package
|
||||||
// RUN: %target-swift-frontend -typecheck %t/src/TestSamePackage.swift \
|
// RUN: %target-swift-frontend -typecheck %t/src/TestSamePackage.swift \
|
||||||
@@ -26,6 +29,8 @@
|
|||||||
// RUN: -package-name Test \
|
// RUN: -package-name Test \
|
||||||
// RUN: -verify
|
// RUN: -verify
|
||||||
|
|
||||||
|
// REQUIRES: swift_feature_ExtensibleAttribute
|
||||||
|
|
||||||
//--- Lib.swift
|
//--- Lib.swift
|
||||||
|
|
||||||
@extensible
|
@extensible
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// RUN: %target-typecheck-verify-swift
|
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ExtensibleAttribute
|
||||||
|
|
||||||
|
// REQUIRES: swift_feature_ExtensibleAttribute
|
||||||
|
|
||||||
@extensible
|
@extensible
|
||||||
public enum E1 { // Ok
|
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 -disable-experimental-parser-round-trip -verify-additional-prefix disabled-
|
||||||
// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature CompileTimeValues
|
// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature CompileTimeValues -enable-experimental-feature ExtensibleAttribute
|
||||||
|
|
||||||
// REQUIRES: asserts
|
// REQUIRES: asserts
|
||||||
|
|
||||||
@@ -14,3 +14,13 @@ public let x = 1 // expected-disabled-error@-1 {{'const' attribute is only vali
|
|||||||
#else
|
#else
|
||||||
#error("doesn't have @const") // expected-disabled-error {{doesn't have @const}}
|
#error("doesn't have @const") // expected-disabled-error {{doesn't have @const}}
|
||||||
#endif
|
#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