diff --git a/include/swift/AST/DeclAttr.def b/include/swift/AST/DeclAttr.def index 267834c0cd9b8..2ad8584484f19 100644 --- a/include/swift/AST/DeclAttr.def +++ b/include/swift/AST/DeclAttr.def @@ -861,7 +861,6 @@ DECL_ATTR(abi, ABI, OnConstructor | OnFunc | OnSubscript | OnVar, LongAttribute | ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove | ForbiddenInABIAttr, 165) -DECL_ATTR_FEATURE_REQUIREMENT(ABI, ABIAttribute) // Unused '166': Used to be `@execution(caller | concurrent)` replaced with `@concurrent` and `nonisolated(nonsending)` diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 4a391ceb1cb1a..7a3130de47b53 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -8468,14 +8468,10 @@ ERROR(attr_abi_mismatched_async,none, "cannot give %0 the ABI of %select{a non-async|an async}1 %kindonly0", (Decl *, /*abiIsAsync=*/bool)) -ERROR(attr_abi_mismatched_pbd_size,none, - "cannot give pattern binding the ABI of a binding with " - "%select{more|fewer}0 patterns", - (/*abiHasExtra=*/bool)) - -ERROR(attr_abi_mismatched_var,none, - "no match for %select{%kind0 in the ABI|ABI %kind0}1", - (Decl *, /*isABI=*/bool)) +ERROR(attr_abi_multiple_vars,none, + "'abi' attribute can only be applied to a single %0; declare each " + "%0 separately", + (DescriptiveDeclKind)) ERROR(attr_abi_incompatible_with_silgen_name,none, "cannot use '@_silgen_name' and '@abi' on the same %kindonly0 because " diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index ec87796ba0103..6b3a7f1f6a94b 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -257,6 +257,7 @@ LANGUAGE_FEATURE(SendableCompletionHandlers, 463, "Objective-C completion handle LANGUAGE_FEATURE(AsyncExecutionBehaviorAttributes, 0, "@concurrent and nonisolated(nonsending)") LANGUAGE_FEATURE(IsolatedConformances, 407, "Global-actor isolated conformances") LANGUAGE_FEATURE(ValueGenericsNameLookup, 452, "Value generics appearing as static members for namelookup") +SUPPRESSIBLE_LANGUAGE_FEATURE(ABIAttributeSE0479, 479, "@abi attribute on functions, initializers, properties, and subscripts") // Swift 6 UPCOMING_FEATURE(ConciseMagicFile, 274, 6) @@ -487,9 +488,6 @@ EXPERIMENTAL_FEATURE(CoroutineAccessorsUnwindOnCallerError, false) EXPERIMENTAL_FEATURE(AddressableParameters, true) SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AddressableTypes, true) -/// Allow the @abi attribute. -SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ABIAttribute, true) - /// Allow custom availability domains to be defined and referenced. EXPERIMENTAL_FEATURE(CustomAvailability, true) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 3a9b306189951..f2c10773e2ca1 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -3289,8 +3289,8 @@ suppressingFeatureCoroutineAccessors(PrintOptions &options, } static void -suppressingFeatureABIAttribute(PrintOptions &options, - llvm::function_ref action) { +suppressingFeatureABIAttributeSE0479(PrintOptions &options, + llvm::function_ref action) { llvm::SaveAndRestore scope1(options.PrintSyntheticSILGenName, true); ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::ABI); action(); diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index 9501fe6a7c4aa..b4667b352ef85 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -388,7 +388,7 @@ static ABIAttr *getABIAttr(Decl *decl) { return decl->getAttrs().getAttribute(); } -static bool usesFeatureABIAttribute(Decl *decl) { +static bool usesFeatureABIAttributeSE0479(Decl *decl) { return getABIAttr(decl) != nullptr; } diff --git a/lib/ASTGen/Sources/ASTGen/SourceFile.swift b/lib/ASTGen/Sources/ASTGen/SourceFile.swift index d7692a4641607..ada0514e033a8 100644 --- a/lib/ASTGen/Sources/ASTGen/SourceFile.swift +++ b/lib/ASTGen/Sources/ASTGen/SourceFile.swift @@ -75,7 +75,6 @@ extension Parser.ExperimentalFeatures { mapFeature(.NonescapableTypes, to: .nonescapableTypes) mapFeature(.TrailingComma, to: .trailingComma) mapFeature(.CoroutineAccessors, to: .coroutineAccessors) - mapFeature(.ABIAttribute, to: .abiAttribute) mapFeature(.OldOwnershipOperatorSpellings, to: .oldOwnershipOperatorSpellings) mapFeature(.KeyPathWithMethodMembers, to: .keypathWithMethodMembers) mapFeature(.InlineArrayTypeSugar, to: .inlineArrayTypeSugar) diff --git a/lib/Sema/TypeCheckAttrABI.cpp b/lib/Sema/TypeCheckAttrABI.cpp index 1049b7058f242..07fab92e98a82 100644 --- a/lib/Sema/TypeCheckAttrABI.cpp +++ b/lib/Sema/TypeCheckAttrABI.cpp @@ -1102,60 +1102,29 @@ class ABIDeclChecker : public ASTComparisonVisitor { }; void checkABIAttrPBD(PatternBindingDecl *APBD, VarDecl *VD) { - auto &diags = VD->getASTContext().Diags; auto PBD = VD->getParentPatternBinding(); - // To make sure we only diagnose this stuff once, check that VD is the first - // anchoring variable in the PBD. - bool isFirstAnchor = false; + Decl *anchorVD = nullptr; for (auto i : range(PBD->getNumPatternEntries())) { - auto anchorVD = PBD->getAnchoringVarDecl(i); - if (anchorVD) { - isFirstAnchor = (anchorVD == VD); + anchorVD = PBD->getAnchoringVarDecl(i); + if (anchorVD) break; - } } - if (!isFirstAnchor) + // To make sure we only diagnose this stuff once, check that VD is the + // first anchoring variable in the PBD. + if (anchorVD != VD) return; - // Check that the PBDs have the same number of patterns. - if (PBD->getNumPatternEntries() < APBD->getNumPatternEntries()) { - diags.diagnose(APBD->getPattern(PBD->getNumPatternEntries())->getLoc(), - diag::attr_abi_mismatched_pbd_size, /*abiHasExtra=*/false); - return; - } - if (PBD->getNumPatternEntries() > APBD->getNumPatternEntries()) { - diags.diagnose(PBD->getPattern(APBD->getNumPatternEntries())->getLoc(), - diag::attr_abi_mismatched_pbd_size, /*abiHasExtra=*/true); + // In the final approved feature, we only permit single-variable patterns. + // (However, the rest of the compiler tolerates them.) + if (!PBD->getSingleVar() || !APBD->getSingleVar()) { + PBD->diagnose(diag::attr_abi_multiple_vars, + anchorVD ? anchorVD->getDescriptiveKind() + : PBD->getDescriptiveKind()); return; } - // Check that each pattern has the same number of variables. - bool didDiagnose = false; - for (auto i : range(PBD->getNumPatternEntries())) { - SmallVector VDs; - SmallVector AVDs; - - PBD->getPattern(i)->collectVariables(VDs); - APBD->getPattern(i)->collectVariables(AVDs); - - if (VDs.size() < AVDs.size()) { - for (auto AVD : drop_begin(AVDs, VDs.size())) { - AVD->diagnose(diag::attr_abi_mismatched_var, AVD, /*isABI=*/true); - didDiagnose = true; - } - } - else if (VDs.size() > AVDs.size()) { - for (auto VD : drop_begin(VDs, AVDs.size())) { - VD->diagnose(diag::attr_abi_mismatched_var, VD, /*isABI=*/false); - didDiagnose = true; - } - } - } - if (didDiagnose) - return; - // Check the ABI PBD--this is what checks the underlying vars. TypeChecker::typeCheckDecl(APBD); } diff --git a/test/ASTGen/attrs.swift b/test/ASTGen/attrs.swift index 39c8f5379eb9c..9b9c3aba5e497 100644 --- a/test/ASTGen/attrs.swift +++ b/test/ASTGen/attrs.swift @@ -1,7 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %target-swift-frontend-dump-parse \ -// RUN: -enable-experimental-feature ABIAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ // RUN: -enable-experimental-feature RawLayout \ @@ -12,7 +11,6 @@ // RUN: | %sanitize-address > %t/astgen.ast // RUN: %target-swift-frontend-dump-parse \ -// RUN: -enable-experimental-feature ABIAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ // RUN: -enable-experimental-feature RawLayout \ @@ -26,7 +24,6 @@ // RUN: %target-typecheck-verify-swift \ // RUN: -module-abi-name ASTGen \ // RUN: -enable-experimental-feature ParserASTGen \ -// RUN: -enable-experimental-feature ABIAttribute \ // RUN: -enable-experimental-feature Extern \ // RUN: -enable-experimental-feature LifetimeDependence \ // RUN: -enable-experimental-feature RawLayout \ @@ -38,7 +35,6 @@ // REQUIRES: executable_test // REQUIRES: swift_swift_parser // REQUIRES: swift_feature_ParserASTGen -// REQUIRES: swift_feature_ABIAttribute // REQUIRES: swift_feature_Extern // REQUIRES: swift_feature_LifetimeDependence // REQUIRES: swift_feature_RawLayout diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index 7489b6035359d..a7104e38d3dc3 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -19,6 +19,11 @@ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=KEYWORD_INDEPENDENT_2 | %FileCheck %s -check-prefix=KEYWORD_LAST // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=KEYWORD_LAST | %FileCheck %s -check-prefix=KEYWORD_LAST +// NOTE: If you want to test code completion for an experimental feature, please +// put your tests in complete_decl_attribute_feature_requirement.swift, not +// here. That file has the infrastructure to test that completions are not +// offered when the feature is disabled. + struct MyStruct {} @propertyWrapper @@ -112,6 +117,7 @@ actor MyGenericGlobalActor { // KEYWORD2-NEXT: Keyword/None: preconcurrency[#Func Attribute#]; name=preconcurrency // KEYWORD2-NEXT: Keyword/None: backDeployed[#Func Attribute#]; name=backDeployed // KEYWORD2-NEXT: Keyword/None: lifetime[#Func Attribute#]; name=lifetime +// KEYWORD2-NEXT: Keyword/None: abi[#Func Attribute#]; name=abi{{$}} // KEYWORD2-NEXT: Keyword/None: concurrent[#Func Attribute#]; name=concurrent // KEYWORD2-NOT: Keyword // KEYWORD2-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct @@ -169,6 +175,7 @@ actor MyGenericGlobalActor { // KEYWORD5-NEXT: Keyword/None: preconcurrency[#Struct Attribute#]; name=preconcurrency @#^ON_GLOBALVAR^# var globalVar +// ON_GLOBALVAR-DAG: Keyword/None: abi[#Var Attribute#]; name=abi // ON_GLOBALVAR-DAG: Keyword/None: available[#Var Attribute#]; name=available // ON_GLOBALVAR-DAG: Keyword/None: objc[#Var Attribute#]; name=objc // ON_GLOBALVAR-DAG: Keyword/None: NSCopying[#Var Attribute#]; name=NSCopying @@ -197,6 +204,7 @@ actor MyGenericGlobalActor { struct _S { @#^ON_INIT^# init() +// ON_INIT-DAG: Keyword/None: abi[#Constructor Attribute#]; name=abi // ON_INIT-DAG: Keyword/None: available[#Constructor Attribute#]; name=available // ON_INIT-DAG: Keyword/None: objc[#Constructor Attribute#]; name=objc // ON_INIT-DAG: Keyword/None: inline[#Constructor Attribute#]; name=inline @@ -207,6 +215,7 @@ struct _S { // ON_INIT-DAG: Keyword/None: preconcurrency[#Constructor Attribute#]; name=preconcurrency @#^ON_PROPERTY^# var foo +// ON_PROPERTY-DAG: Keyword/None: abi[#Var Attribute#]; name=abi // ON_PROPERTY-DAG: Keyword/None: available[#Var Attribute#]; name=available // ON_PROPERTY-DAG: Keyword/None: objc[#Var Attribute#]; name=objc // ON_PROPERTY-DAG: Keyword/None: NSCopying[#Var Attribute#]; name=NSCopying @@ -234,8 +243,12 @@ struct _S { // ON_PROPERTY-DAG: Decl[Actor]/CurrModule/TypeRelation[Convertible]: MyGenericGlobalActor[#Global Actor#]; name=MyGenericGlobalActor // ON_PROPERTY-NOT: Decl[PrecedenceGroup] + @#^ON_SUBSCR^# subscript +// ON_SUBSCR-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi + @#^ON_METHOD^# private func foo() +// ON_METHOD-DAG: Keyword/None: abi[#Func Attribute#]; name=abi // ON_METHOD-DAG: Keyword/None: available[#Func Attribute#]; name=available // ON_METHOD-DAG: Keyword/None: objc[#Func Attribute#]; name=objc // ON_METHOD-DAG: Keyword/None: IBAction[#Func Attribute#]; name=IBAction @@ -293,6 +306,7 @@ struct _S { @#^ON_MEMBER_LAST^# +// ON_MEMBER_LAST-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi // ON_MEMBER_LAST-DAG: Keyword/None: available[#Declaration Attribute#]; name=available // ON_MEMBER_LAST-DAG: Keyword/None: objc[#Declaration Attribute#]; name=objc // ON_MEMBER_LAST-DAG: Keyword/None: dynamicCallable[#Declaration Attribute#]; name=dynamicCallable @@ -347,6 +361,8 @@ func takeClosure(_: () -> Void) { print("x") } } +// FIXME: Not valid in this position (but CompletionLookup can't tell that) +// IN_CLOSURE-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi // FIXME: We should mark MyPropertyWrapper and MyResultBuilder as Unrelated // IN_CLOSURE-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct // IN_CLOSURE-DAG: Decl[Struct]/CurrModule/TypeRelation[Convertible]: MyPropertyWrapper[#Property Wrapper#]; name=MyPropertyWrapper @@ -365,6 +381,7 @@ func dummy2() {} @#^KEYWORD_LAST^# +// KEYWORD_LAST-DAG: Keyword/None: abi[#Declaration Attribute#]; name=abi // KEYWORD_LAST-DAG: Keyword/None: available[#Declaration Attribute#]; name=available{{$}} // KEYWORD_LAST-DAG: Keyword/None: freestanding[#Declaration Attribute#]; name=freestanding{{$}} // KEYWORD_LAST-DAG: Keyword/None: objc[#Declaration Attribute#]; name=objc{{$}} diff --git a/test/IDE/complete_decl_attribute_feature_requirement.swift b/test/IDE/complete_decl_attribute_feature_requirement.swift index 4208fcd4ebdf0..256f5da3345d0 100644 --- a/test/IDE/complete_decl_attribute_feature_requirement.swift +++ b/test/IDE/complete_decl_attribute_feature_requirement.swift @@ -3,6 +3,11 @@ // it's enabled. When a feature becomes non-experimental, move its test cases // into the normal complete_decl_attribute.swift test file. +// NOTE: There are currently no experimental features that need code completion +// testing, but this test file is being left in place for when it's needed +// again. At that time, please remove the ABIAttribute tests. +// REQUIRES: new_use_case + // REQUIRES: asserts // RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED diff --git a/test/IRGen/asmname.swift b/test/IRGen/asmname.swift index 50d40110adfb7..6f1236dd4818d 100644 --- a/test/IRGen/asmname.swift +++ b/test/IRGen/asmname.swift @@ -1,9 +1,8 @@ -// RUN: %target-swift-frontend -enable-experimental-feature ABIAttribute %s -emit-ir > %t.ir +// RUN: %target-swift-frontend %s -emit-ir > %t.ir // RUN: %FileCheck --input-file %t.ir %s // RUN: %FileCheck --check-prefix NEGATIVE --input-file %t.ir %s // REQUIRES: CPU=i386 || CPU=x86_64 || CPU=arm64 -// REQUIRES: swift_feature_ABIAttribute // Non-Swift _silgen_name definitions diff --git a/test/Macros/macro_expand.swift b/test/Macros/macro_expand.swift index 740c20b0461c9..074fcb5a6bd54 100644 --- a/test/Macros/macro_expand.swift +++ b/test/Macros/macro_expand.swift @@ -719,6 +719,29 @@ func testPropertyWrapperMacro() { #hasPropertyWrapperParam($x: .init(wrappedValue: 0)) } +#if swift(>=1.0) && TEST_DIAGNOSTICS +// Test that macros can't be used in @abi + +struct ABIAttrWithFreestandingMacro1 { + // expected-error@+1 {{cannot use pound literal in '@abi'}} + @abi(#varValue) + #varValue + // expected-note@-1 {{in expansion of macro 'varValue' here}} +} + +struct ABIAttrWithFreestandingMacro2 { + // expected-error@+1 {{cannot use pound literal in '@abi'}} + @abi(#varValue) + var value: Int { 0 } +} + +struct ABIAttrWithFreestandingMacro3 { + @abi(var value: Int) + #varValue +} + +#endif + #if TEST_DIAGNOSTICS @freestanding(expression) macro missingMacro() = #externalMacro(module: "MacroDefinition", type: "BluhBlah") diff --git a/test/Macros/macro_expand_peers.swift b/test/Macros/macro_expand_peers.swift index 99f8febe7fe7f..dfd8a3cc0897a 100644 --- a/test/Macros/macro_expand_peers.swift +++ b/test/Macros/macro_expand_peers.swift @@ -309,3 +309,26 @@ func closuresInPeerMacroCrash() {} @trait(Trait {}) @trait(Trait {}) var closuresInPeerMacroOnVariableCrash: Int = 0 + +// Test that macros can't be used in @abi + +#if swift(>=5.3) && TEST_DIAGNOSTICS +struct ABIAttrWithAttachedMacro { + // expected-error@+1 {{macro 'addCompletionHandler()' cannot be expanded in '@abi' attribute}} + @abi(@addCompletionHandler func fn1() async) + @addCompletionHandler func fn1() async {} + // From diagnostics in the expansion: + // expected-note@-2 3{{in expansion of macro 'addCompletionHandler' on instance method 'fn1()' here}} + // expected-note@-4 {{'fn1()' previously declared here}} + + // expected-error@+1 {{macro 'addCompletionHandler()' cannot be expanded in '@abi' attribute}} + @abi(@addCompletionHandler func fn2() async) + func fn2() async {} + + @abi(func fn3() async) + @addCompletionHandler func fn3() async {} + // From diagnostics in the expansion: + // expected-note@-2 2{{in expansion of macro 'addCompletionHandler' on instance method 'fn3()' here}} + // expected-note@-4 {{'fn3()' previously declared here}} +} +#endif diff --git a/test/ModuleInterface/attrs.swift b/test/ModuleInterface/attrs.swift index e6aef42064184..56da19cc2e346 100644 --- a/test/ModuleInterface/attrs.swift +++ b/test/ModuleInterface/attrs.swift @@ -1,6 +1,5 @@ // RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name attrs \ -// RUN: -emit-private-module-interface-path %t.private.swiftinterface \ -// RUN: -enable-experimental-feature ABIAttribute +// RUN: -emit-private-module-interface-path %t.private.swiftinterface // RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name attrs // RUN: %target-swift-typecheck-module-from-interface(%t.private.swiftinterface) -module-name attrs @@ -8,8 +7,6 @@ // RUN: %FileCheck %s --check-prefixes CHECK,PUBLIC-CHECK --input-file %t.swiftinterface // RUN: %FileCheck %s --check-prefixes CHECK,PRIVATE-CHECK --input-file %t.private.swiftinterface -// REQUIRES: swift_feature_ABIAttribute - // CHECK: @_transparent public func glass() -> Swift.Int { return 0 }{{$}} @_transparent public func glass() -> Int { return 0 } @@ -38,7 +35,7 @@ internal func __specialize_someGenericFunction(_ t: T) -> Int { @abi(func __abi__abiAttrOnFunction(param: Int)) public func abiAttrOnFunction(param: Int) {} -// CHECK: #if {{.*}} $ABIAttribute +// CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(func __abi__abiAttrOnFunction(param: Swift.Int)) // CHECK: public func abiAttrOnFunction(param: Swift.Int) // CHECK: #else @@ -48,7 +45,7 @@ public func abiAttrOnFunction(param: Int) {} @abi(let __abi__abiAttrOnVar: Int) public var abiAttrOnVar: Int = 42 -// CHECK: #if {{.*}} $ABIAttribute +// CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(var __abi__abiAttrOnVar: Swift.Int) // CHECK: public var abiAttrOnVar: Swift.Int // CHECK: #else @@ -57,7 +54,7 @@ public var abiAttrOnVar: Int = 42 // CHECK: #endif public struct MutatingTest { - // CHECK: #if {{.*}} $ABIAttribute + // CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(mutating func abiMutFunc()) // CHECK: public mutating func abiMutFunc() // CHECK: #else @@ -68,14 +65,14 @@ public struct MutatingTest { public mutating func abiMutFunc() {} } -// PUBLIC-CHECK-NOT: #if {{.*}} $ABIAttribute +// PUBLIC-CHECK-NOT: #if {{.*}} $ABIAttributeSE0479 // PUBLIC-CHECK-NOT: @abi(func abiSpiFunc()) // PUBLIC-CHECK-NOT: public func abiSpiFunc() // PUBLIC-CHECK-NOT: #else // PUBLIC-CHECK-NOT: @_silgen_name("$s5attrs10abiSpiFuncyyF") // PUBLIC-CHECK-NOT: public func abiSpiFunc() // PUBLIC-CHECK-NOT: #endif -// PRIVATE-CHECK: #if {{.*}} $ABIAttribute +// PRIVATE-CHECK: #if {{.*}} $ABIAttributeSE0479 // PRIVATE-CHECK: @abi(func abiSpiFunc()) // PRIVATE-CHECK: public func abiSpiFunc() // PRIVATE-CHECK: #else @@ -88,7 +85,7 @@ public struct MutatingTest { // We should print feature guards outside, but not inside, an @abi attribute. @abi(func sendingABI() -> sending Any?) public func sendingABI() -> Any? { nil } -// CHECK: #if {{.*}} && $ABIAttribute +// CHECK: #if {{.*}} && $ABIAttributeSE0479 // CHECK: @abi(func sendingABI() -> sending Any?) // CHECK: public func sendingABI() -> Any? // CHECK: #elseif {{.*}} && $SendingArgsAndResults diff --git a/test/ModuleInterface/attrs_objc.swift b/test/ModuleInterface/attrs_objc.swift index 37cb78318be05..0f8fd5b1f2ca0 100644 --- a/test/ModuleInterface/attrs_objc.swift +++ b/test/ModuleInterface/attrs_objc.swift @@ -1,19 +1,17 @@ // RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s \ -// RUN: -enable-objc-interop -module-name attrs_objc \ -// RUN: -enable-experimental-feature ABIAttribute +// RUN: -enable-objc-interop -module-name attrs_objc // RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name attrs_objc // RUN: %FileCheck %s --input-file %t.swiftinterface // REQUIRES: objc_interop -// REQUIRES: swift_feature_ABIAttribute import Foundation @objcMembers public class ObjCTest: NSObject { - // CHECK: #if {{.*}} $ABIAttribute + // CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(func abiObjCFunc()) // CHECK: @objc public func abiObjCFunc() // CHECK: #else @@ -23,7 +21,7 @@ public class ObjCTest: NSObject { @abi(func abiObjCFunc()) @objc public func abiObjCFunc() {} - // CHECK: #if {{.*}} $ABIAttribute + // CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(func abiImplicitObjCFunc()) // CHECK: @objc public func abiImplicitObjCFunc() // CHECK: #else @@ -33,7 +31,7 @@ public class ObjCTest: NSObject { @abi(func abiImplicitObjCFunc()) public func abiImplicitObjCFunc() {} - // CHECK: #if {{.*}} $ABIAttribute + // CHECK: #if {{.*}} $ABIAttributeSE0479 // CHECK: @abi(func abiIBActionFunc(_: Any)) // CHECK: @objc @IBAction @_Concurrency.MainActor @preconcurrency public func abiIBActionFunc(_: Any) // CHECK: #else diff --git a/test/attr/attr_abi.swift b/test/attr/attr_abi.swift index c8f6913ebf704..49116208b3740 100644 --- a/test/attr/attr_abi.swift +++ b/test/attr/attr_abi.swift @@ -1,6 +1,5 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-feature Extern -enable-experimental-feature ABIAttribute -enable-experimental-feature AddressableParameters -enable-experimental-feature NoImplicitCopy -enable-experimental-feature SymbolLinkageMarkers -enable-experimental-feature StrictMemorySafety -enable-experimental-feature LifetimeDependence -enable-experimental-feature CImplementation -import-bridging-header %S/Inputs/attr_abi.h -parse-as-library -debugger-support +// RUN: %target-typecheck-verify-swift -enable-experimental-feature Extern -enable-experimental-feature AddressableParameters -enable-experimental-feature NoImplicitCopy -enable-experimental-feature SymbolLinkageMarkers -enable-experimental-feature StrictMemorySafety -enable-experimental-feature LifetimeDependence -enable-experimental-feature CImplementation -import-bridging-header %S/Inputs/attr_abi.h -parse-as-library -debugger-support -// REQUIRES: swift_feature_ABIAttribute // REQUIRES: swift_feature_AddressableParameters // REQUIRES: swift_feature_CImplementation // REQUIRES: swift_feature_Extern @@ -279,17 +278,20 @@ var async11Var: Int { get async { fatalError() } } // PBD shape checking // -@abi(var x1, y1: Int) // expected-error {{cannot give pattern binding the ABI of a binding with more patterns}} -var x1: Int = 0 +@abi(var x1, y1: Int) +var x1: Int = 0 // expected-error {{'abi' attribute can only be applied to a single var; declare each var separately}} @abi(var x2: Int) -var x2 = 0, y2: Int = 0 // expected-error {{cannot give pattern binding the ABI of a binding with fewer patterns}} +var x2 = 0, y2: Int = 0 // expected-error {{'abi' attribute can only be applied to a single var; declare each var separately}} -@abi(var (x3, y3): (Int, Int), (a3, b3): (Int, Int)) // expected-error {{no match for ABI var 'b3'}} -var (x3, y3): (Int, Int) = (0, 0), a3: Int = 0 +@abi(var (x3, y3): (Int, Int), (a3, b3): (Int, Int)) +var (x3, y3): (Int, Int) = (0, 0), a3: Int = 0 // expected-error {{'abi' attribute can only be applied to a single var; declare each var separately}} @abi(var (x4, y4): (Int, Int), a4: Int) -var (x4, y4): (Int, Int) = (0, 0), (a4, b4): (Int, Int) = (0, 0) // expected-error {{no match for var 'b4' in the ABI}} +var (x4, y4): (Int, Int) = (0, 0), (a4, b4): (Int, Int) = (0, 0) // expected-error {{'abi' attribute can only be applied to a single var; declare each var separately}} + +@abi(var x5: Int) +var x5: Int = 0 // // Redeclaration diagnostics diff --git a/test/attr/attr_abi_objc.swift b/test/attr/attr_abi_objc.swift index 653e52a1b4989..b16e0ae6c440a 100644 --- a/test/attr/attr_abi_objc.swift +++ b/test/attr/attr_abi_objc.swift @@ -1,6 +1,5 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-feature ABIAttribute -parse-as-library +// RUN: %target-typecheck-verify-swift -parse-as-library -// REQUIRES: swift_feature_ABIAttribute // REQUIRES: objc_interop import Foundation diff --git a/test/attr/attr_weaklinked.swift b/test/attr/attr_weaklinked.swift index a56dbf4bf8ecb..831afa281d32d 100644 --- a/test/attr/attr_weaklinked.swift +++ b/test/attr/attr_weaklinked.swift @@ -1,7 +1,6 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-feature ABIAttribute +// RUN: %target-typecheck-verify-swift // UNSUPPORTED: OS=windows-msvc -// REQUIRES: swift_feature_ABIAttribute @_weakLinked public func f() { } diff --git a/test/attr/feature_requirement.swift b/test/attr/feature_requirement.swift index 383bdac1511a3..eb127063d5a00 100644 --- a/test/attr/feature_requirement.swift +++ b/test/attr/feature_requirement.swift @@ -1,20 +1,11 @@ // 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 -enable-experimental-feature ExtensibleAttribute +// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature ExtensibleAttribute // REQUIRES: asserts // This test checks whether DECL_ATTR_FEATURE_REQUIREMENT is being applied correctly. // It is expected to need occasional edits as experimental features are stabilized. -@abi(func fn()) -func fn() {} // expected-disabled-error@-1 {{'abi' attribute is only valid when experimental feature ABIAttribute is enabled}} - -#if hasAttribute(abi) - #error("does have @abi") // expected-enabled-error {{does have @abi}} -#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}}