Skip to content

Commit 000c260

Browse files
committed
SE-495: Make @c an official feature
1 parent a6cae4a commit 000c260

19 files changed

+43
-43
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,9 +2114,6 @@ ERROR(cdecl_throws,none,
21142114
ERROR(cdecl_incompatible_with_objc,none,
21152115
"cannot apply both '@c' and '@objc' to %kindonly0",
21162116
(const Decl *))
2117-
ERROR(cdecl_feature_required,none,
2118-
"'@c' requires '-enable-experimental-feature CDecl'",
2119-
())
21202117

21212118
// @used and @section
21222119
ERROR(section_empty_name,none,

include/swift/Basic/Features.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ LANGUAGE_FEATURE(LifetimeDependenceMutableAccessors, 0, "Support mutable accesso
277277
LANGUAGE_FEATURE(InoutLifetimeDependence, 0, "Support @_lifetime(&)")
278278
SUPPRESSIBLE_LANGUAGE_FEATURE(NonexhaustiveAttribute, 487, "Nonexhaustive Enums")
279279
LANGUAGE_FEATURE(ModuleSelector, 491, "Module selectors (`Module::name` syntax)")
280+
LANGUAGE_FEATURE(CDecl, 495, "C compatible functions and enums with @c")
280281

281282
// Swift 6
282283
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -529,9 +530,6 @@ EXPERIMENTAL_FEATURE(ClosureBodyMacro, true)
529530
/// Allow declarations of Swift runtime symbols using @_silgen_name.
530531
EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)
531532

532-
/// Allow use of `@c`
533-
EXPERIMENTAL_FEATURE(CDecl, false)
534-
535533
/// Allow use of `using` declaration that control default isolation
536534
/// in a file scope.
537535
EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,12 +2486,6 @@ void AttributeChecker::visitCDeclAttr(CDeclAttr *attr) {
24862486
if (D->getAttrs().getAttribute<ObjCAttr>()) {
24872487
diagnose(attr->getLocation(), diag::cdecl_incompatible_with_objc, D);
24882488
}
2489-
2490-
// @c needs to be enabled via a feature flag.
2491-
if (!attr->Underscored &&
2492-
!Ctx.LangOpts.hasFeature(Feature::CDecl)) {
2493-
diagnose(attr->getLocation(), diag::cdecl_feature_required);
2494-
}
24952489
}
24962490

24972491
void AttributeChecker::visitExposeAttr(ExposeAttr *attr) {

test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public struct Strct {
181181
public let transform2: ns.anonStructInNS
182182
}
183183

184+
// CHECK: #if __has_feature(objc_modules)
184185
// CHECK: #if __has_feature(objc_modules)
185186
// CHECK: #if __has_feature(objc_modules)
186187
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")

test/Parse/objc_enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum NonObjCEnum: Int {
2626

2727
class Bar {
2828
@objc func foo(x: Foo) {}
29-
@objc func nonObjC(x: NonObjCEnum) {} //expected-error{{type of the parameter cannot be represented in Objective-C}} //expected-note{{non-'@objc' enums cannot be represented in Objective-C}}
29+
@objc func nonObjC(x: NonObjCEnum) {} //expected-error{{type of the parameter cannot be represented in Objective-C}} //expected-note{{Swift enums not marked '@c' or '@objc' cannot be represented in Objective-C}}
3030
}
3131

3232
// <rdar://problem/23681566> @objc enums with payloads rejected with no source location info

test/PrintAsObjC/emit-clang-header-nonmodular-includes-mock-sdk.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class HelloWorld: NSObject {
2424
}
2525
}
2626

27+
// CHECK: #if __has_feature(objc_modules)
2728
// CHECK: #if __has_feature(objc_modules)
2829
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
2930
// CHECK-NEXT: #pragma clang diagnostic ignored "-Watimport-in-framework-header"

test/PrintAsObjC/emit-clang-header-nonmodular-includes-modulemap-not-in-include-dir.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import EmitClangHeaderNonmodularIncludesStressTest
1111

1212
public class Bar : Baz {}
1313

14+
// CHECK: #if __has_feature(objc_modules)
1415
// CHECK: #if __has_feature(objc_modules)
1516
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
1617
// CHECK-NEXT: #pragma clang diagnostic ignored "-Watimport-in-framework-header"

test/PrintAsObjC/emit-clang-header-nonmodular-includes-path-normalization.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import EmitClangHeaderNonmodularIncludesStressTest
99

1010
public class Bar : Baz {}
1111

12+
// CHECK: #if __has_feature(objc_modules)
1213
// CHECK: #if __has_feature(objc_modules)
1314
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
1415
// CHECK-NEXT: #pragma clang diagnostic ignored "-Watimport-in-framework-header"

test/PrintAsObjC/emit-clang-header-nonmodular-includes-symlinked-header.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import EmitClangHeaderNonmodularIncludesStressTest
1111
public class Bar : Foo {}
1212

1313

14+
// CHECK: #if __has_feature(objc_modules)
1415
// CHECK: #if __has_feature(objc_modules)
1516
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
1617
// CHECK-NEXT: #pragma clang diagnostic ignored "-Watimport-in-framework-header"

test/PrintAsObjC/empty.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
// CHECK-NEXT: #endif
4242
// CHECK-NEXT: #endif
4343

44+
// CHECK: #if defined(__cplusplus)
45+
// CHECK-NEXT: extern "C" {
46+
// CHECK-NEXT: #endif
47+
48+
// CHECK: #if defined(__cplusplus)
49+
// CHECK-NEXT: } // extern "C"
50+
// CHECK-NEXT: #endif
4451

4552
// CHECK-NOT: {{[@;{}]}}
4653

0 commit comments

Comments
 (0)