Skip to content

Commit 1e34dbc

Browse files
authored
Merge pull request swiftlang#75335 from jckarter/extern-is-experimental-6.0
[6.0] `@_extern` is an experimental feature.
2 parents 467e6a1 + 345e5a1 commit 1e34dbc

15 files changed

+25
-38
lines changed

include/swift/Basic/Features.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
186186
SUPPRESSIBLE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
187187
LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")
188188
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(OptionalIsolatedParameters, 420, "Optional isolated parameters")
189-
SUPPRESSIBLE_LANGUAGE_FEATURE(Extern, 0, "@_extern")
190189
LANGUAGE_FEATURE(ExpressionMacroDefaultArguments, 422, "Expression macro as caller-side default argument")
191190
LANGUAGE_FEATURE(BuiltinStoreRaw, 0, "Builtin.storeRaw")
192191
LANGUAGE_FEATURE(BuiltinCreateTask, 0, "Builtin.createTask and Builtin.createDiscardingTask")
@@ -389,6 +388,8 @@ EXPERIMENTAL_FEATURE(ReinitializeConsumeInMultiBlockDefer, false)
389388

390389
EXPERIMENTAL_FEATURE(SE427NoInferenceOnExtension, false)
391390

391+
EXPERIMENTAL_FEATURE(Extern, true)
392+
392393
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
393394
#undef EXPERIMENTAL_FEATURE
394395
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ static bool usesFeatureOptionalIsolatedParameters(Decl *decl) {
338338
return false;
339339
}
340340

341-
static bool usesFeatureExtern(Decl *decl) {
342-
return decl->getAttrs().hasAttribute<ExternAttr>();
343-
}
344-
345341
static bool usesFeatureAssociatedTypeImplements(Decl *decl) {
346342
return isa<TypeDecl>(decl) && decl->getAttrs().hasAttribute<ImplementsAttr>();
347343
}
@@ -698,6 +694,7 @@ UNINTERESTING_FEATURE(NonfrozenEnumExhaustivity)
698694
UNINTERESTING_FEATURE(BorrowingSwitch)
699695

700696
UNINTERESTING_FEATURE(ClosureIsolation)
697+
UNINTERESTING_FEATURE(Extern)
701698

702699
static bool usesFeatureConformanceSuppression(Decl *decl) {
703700
auto *nominal = dyn_cast<NominalTypeDecl>(decl);

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,8 @@ static bool isCCompatibleFuncDecl(FuncDecl *FD) {
22662266
}
22672267

22682268
void AttributeChecker::visitExternAttr(ExternAttr *attr) {
2269-
if (!Ctx.LangOpts.hasFeature(Feature::Extern)) {
2269+
if (!Ctx.LangOpts.hasFeature(Feature::Extern)
2270+
&& !D->getModuleContext()->isStdlibModule()) {
22702271
diagnoseAndRemoveAttr(attr, diag::attr_extern_experimental);
22712272
return;
22722273
}

test/ModuleInterface/extern_attr.swift

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,11 @@
44
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -module-name Library
55
// RUN: %FileCheck %s < %t/Library.swiftinterface
66

7-
// CHECK: #if compiler(>=5.3) && $Extern
8-
// CHECK-NEXT: @_extern(c) public func externalCFunc()
9-
// CHECK-NEXT: #else
10-
// CHECK-NEXT: public func externalCFunc()
11-
// CHECK-NEXT: #endif
7+
// CHECK: @_extern(c) public func externalCFunc()
128
@_extern(c) public func externalCFunc()
139

14-
// CHECK: #if compiler(>=5.3) && $Extern
15-
// CHECK-NEXT: @_extern(c, "renamedCFunc") public func externalRenamedCFunc()
16-
// CHECK-NEXT: #else
17-
// CHECK-NEXT: public func externalRenamedCFunc()
18-
// CHECK-NEXT: #endif
10+
// CHECK: @_extern(c, "renamedCFunc") public func externalRenamedCFunc()
1911
@_extern(c, "renamedCFunc") public func externalRenamedCFunc()
2012

21-
// CHECK: #if compiler(>=5.3) && $Extern
22-
// CHECK-NEXT: @_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()
23-
// CHECK-NEXT: #else
24-
// CHECK-NEXT: public func wasmImportedFunc()
25-
// CHECK-NEXT: #endif
13+
// CHECK: @_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()
2614
@_extern(wasm, module: "m", name: "f") public func wasmImportedFunc()

test/embedded/array-to-pointer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -enable-experimental-feature Embedded -c -o %t/main.o
2+
// RUN: %target-swift-frontend %s -enable-experimental-feature Extern -enable-experimental-feature Embedded -c -o %t/main.o
33
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
44
// RUN: %target-clang %t/main.o %t/print.o -o %t/a.out -dead_strip
55
// RUN: %target-run %t/a.out | %FileCheck %s

test/embedded/arrays.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -enable-experimental-feature Embedded -c -o %t/main.o
2+
// RUN: %target-swift-frontend -enable-experimental-feature Extern %s -enable-experimental-feature Embedded -c -o %t/main.o
33
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
44
// RUN: %target-clang %t/main.o %t/print.o -o %t/a.out -dead_strip
55
// RUN: %target-run %t/a.out | %FileCheck %s

test/embedded/collection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
2+
// RUN: %target-swift-frontend -enable-experimental-feature Extern -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
33
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
44
// RUN: %target-clang %t/a.o %t/print.o -o %t/a.out
55
// RUN: %target-run %t/a.out | %FileCheck %s

test/embedded/custom-print.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
2+
// RUN: %target-swift-frontend -enable-experimental-feature Extern -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
33
// RUN: %target-clang %t/a.o -o %t/a.out
44
// RUN: %target-run %t/a.out | %FileCheck %s
55

test/embedded/dependencies-no-allocations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -no-allocations %s -c -o %t/a.o
2+
// RUN: %target-swift-frontend -enable-experimental-feature Extern -enable-experimental-feature Embedded -no-allocations %s -c -o %t/a.o
33

44
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt
55

test/embedded/dependencies.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o
2+
// RUN: %target-swift-frontend -parse-as-library -enable-experimental-feature Extern -enable-experimental-feature Embedded %s -c -o %t/a.o
33

44
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt
55

0 commit comments

Comments
 (0)