Skip to content

Commit

Permalink
AST: Promote Extern feature to baseline.
Browse files Browse the repository at this point in the history
  • Loading branch information
tshortli committed Jul 9, 2024
1 parent 365d26e commit 8dad141
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
2 changes: 1 addition & 1 deletion include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
SUPPRESSIBLE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
BASELINE_LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(OptionalIsolatedParameters, 420, "Optional isolated parameters")
SUPPRESSIBLE_LANGUAGE_FEATURE(Extern, 0, "@_extern")
BASELINE_LANGUAGE_FEATURE(Extern, 0, "@_extern")
BASELINE_LANGUAGE_FEATURE(ExpressionMacroDefaultArguments, 422, "Expression macro as caller-side default argument")
LANGUAGE_FEATURE(BuiltinStoreRaw, 0, "Builtin.storeRaw")
BASELINE_LANGUAGE_FEATURE(BuiltinCreateTask, 0, "Builtin.createTask and Builtin.createDiscardingTask")
Expand Down
8 changes: 0 additions & 8 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3051,14 +3051,6 @@ static void suppressingFeatureRetroactiveAttribute(
action();
}

static void suppressingFeatureExtern(PrintOptions &options,
llvm::function_ref<void()> action) {
unsigned originalExcludeAttrCount = options.ExcludeAttrList.size();
options.ExcludeAttrList.push_back(DeclAttrKind::Extern);
action();
options.ExcludeAttrList.resize(originalExcludeAttrCount);
}

static void suppressingFeatureIsolatedAny(PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);
Expand Down
4 changes: 0 additions & 4 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ static bool usesFeatureOptionalIsolatedParameters(Decl *decl) {
return false;
}

static bool usesFeatureExtern(Decl *decl) {
return decl->getAttrs().hasAttribute<ExternAttr>();
}

static bool usesFeatureAssociatedTypeImplements(Decl *decl) {
return isa<TypeDecl>(decl) && decl->getAttrs().hasAttribute<ImplementsAttr>();
}
Expand Down
18 changes: 3 additions & 15 deletions test/ModuleInterface/extern_attr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -module-name Library
// RUN: %FileCheck %s < %t/Library.swiftinterface

// CHECK: #if compiler(>=5.3) && $Extern
// CHECK-NEXT: @_extern(c) public func externalCFunc()
// CHECK-NEXT: #else
// CHECK-NEXT: public func externalCFunc()
// CHECK-NEXT: #endif
// CHECK: @_extern(c) public func externalCFunc()
@_extern(c) public func externalCFunc()

// CHECK: #if compiler(>=5.3) && $Extern
// CHECK-NEXT: @_extern(c, "renamedCFunc") public func externalRenamedCFunc()
// CHECK-NEXT: #else
// CHECK-NEXT: public func externalRenamedCFunc()
// CHECK-NEXT: #endif
// CHECK: @_extern(c, "renamedCFunc") public func externalRenamedCFunc()
@_extern(c, "renamedCFunc") public func externalRenamedCFunc()

// CHECK: #if compiler(>=5.3) && $Extern
// CHECK-NEXT: @_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()
// CHECK-NEXT: #else
// CHECK-NEXT: public func wasmImportedFunc()
// CHECK-NEXT: #endif
// CHECK: @_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()
@_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()

0 comments on commit 8dad141

Please sign in to comment.