Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2114,9 +2114,6 @@ ERROR(cdecl_throws,none,
ERROR(cdecl_incompatible_with_objc,none,
"cannot apply both '@c' and '@objc' to %kindonly0",
(const Decl *))
ERROR(cdecl_feature_required,none,
"'@c' requires '-enable-experimental-feature CDecl'",
())

// @used and @section
ERROR(section_empty_name,none,
Expand Down Expand Up @@ -6704,8 +6701,6 @@ NOTE(not_objc_swift_class,none,
NOTE(not_objc_swift_struct,none,
"Swift structs cannot be represented in %" FOREIGN_LANG_SELECT "0",
(ForeignLanguage))
NOTE(not_objc_swift_enum,none,
"non-'@objc' enums cannot be represented in Objective-C", ())
NOTE(not_cdecl_or_objc_swift_enum,none,
"Swift enums not marked '@c'%select{| or '@objc'}0 cannot be "
"represented in %" FOREIGN_LANG_SELECT "0",
Expand Down
6 changes: 0 additions & 6 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,6 @@ EXPERIMENTAL_FEATURE(ClosureIsolation, true)
// staging purposes.
EXPERIMENTAL_FEATURE(ObjCImplementationWithResilientStorage, true)

// Enable @implementation on @_cdecl functions.
EXPERIMENTAL_FEATURE(CImplementation, true)

// Enable @sensitive attribute.
EXPERIMENTAL_FEATURE(Sensitive, true)

Expand Down Expand Up @@ -529,9 +526,6 @@ EXPERIMENTAL_FEATURE(ClosureBodyMacro, true)
/// Allow declarations of Swift runtime symbols using @_silgen_name.
EXPERIMENTAL_FEATURE(AllowRuntimeSymbolDeclarations, true)

/// Allow use of `@c`
EXPERIMENTAL_FEATURE(CDecl, false)

/// Allow use of `using` declaration that control default isolation
/// in a file scope.
EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
Expand Down
6 changes: 0 additions & 6 deletions lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ UNINTERESTING_FEATURE(IsolatedAny2)
UNINTERESTING_FEATURE(GlobalActorIsolatedTypesUsability)
UNINTERESTING_FEATURE(ObjCImplementation)
UNINTERESTING_FEATURE(ObjCImplementationWithResilientStorage)
UNINTERESTING_FEATURE(CImplementation)
UNINTERESTING_FEATURE(Sensitive)
UNINTERESTING_FEATURE(DebugDescriptionMacro)
UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
Expand Down Expand Up @@ -322,11 +321,6 @@ static bool usesFeatureClosureBodyMacro(Decl *decl) {
return false;
}

static bool usesFeatureCDecl(Decl *decl) {
auto attr = decl->getAttrs().getAttribute<CDeclAttr>();
return attr && !attr->Underscored;
}

UNINTERESTING_FEATURE(StrictMemorySafety)
UNINTERESTING_FEATURE(LibraryEvolution)
UNINTERESTING_FEATURE(SafeInteropWrappers)
Expand Down
14 changes: 4 additions & 10 deletions lib/PrintAsClang/ModuleContentsWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,16 +542,10 @@ class ModuleWriter {
assert(ED->isCCompatibleEnum() || ED->hasClangNode());

forwardDeclare(ED, [&]{
if (ED->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
// Forward declare in a way to be compatible with older C standards.
os << "typedef SWIFT_ENUM_FWD_DECL(";
printer.print(ED->getRawType());
os << ", " << getNameForObjC(ED) << ")\n";
} else {
os << "enum " << getNameForObjC(ED) << " : ";
printer.print(ED->getRawType());
os << ";\n";
}
// Forward declare in a way to be compatible with older C standards.
os << "typedef SWIFT_ENUM_FWD_DECL(";
printer.print(ED->getRawType());
os << ", " << getNameForObjC(ED) << ")\n";
});
}

Expand Down
28 changes: 13 additions & 15 deletions lib/PrintAsClang/PrintAsClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,18 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
static_assert(SWIFT_MAX_IMPORTED_SIMD_ELEMENTS == 4,
"need to add SIMD typedefs here if max elements is increased");

if (ctx.LangOpts.hasFeature(Feature::CDecl)) {
// For C compilers which don’t support nullability attributes, ignore them;
// for ones which do, suppress warnings about them being an extension.
out << "#if !__has_feature(nullability)\n"
"# define _Nonnull\n"
"# define _Nullable\n"
"# define _Null_unspecified\n"
"#elif !defined(__OBJC__)\n"
"# pragma clang diagnostic ignored \"-Wnullability-extension\"\n"
"#endif\n"
"#if !__has_feature(nullability_nullable_result)\n"
"# define _Nullable_result _Nullable\n"
"#endif\n";
}
// For C compilers which don’t support nullability attributes, ignore them;
// for ones which do, suppress warnings about them being an extension.
out << "#if !__has_feature(nullability)\n"
"# define _Nonnull\n"
"# define _Nullable\n"
"# define _Null_unspecified\n"
"#elif !defined(__OBJC__)\n"
"# pragma clang diagnostic ignored \"-Wnullability-extension\"\n"
"#endif\n"
"#if !__has_feature(nullability_nullable_result)\n"
"# define _Nullable_result _Nullable\n"
"#endif\n";
}

static int compareImportModulesByName(const ImportModuleTy *left,
Expand Down Expand Up @@ -618,7 +616,7 @@ bool swift::printAsClangHeader(raw_ostream &os, ModuleDecl *M,

// C content (@c)
std::string moduleContentsScratch;
if (M->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
{
SmallPtrSet<ImportModuleTy, 8> imports;
llvm::raw_string_ostream cModuleContents{moduleContentsScratch};
printModuleContentsAsC(cModuleContents, imports, *M, interopContext,
Expand Down
9 changes: 0 additions & 9 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,9 +1841,6 @@ visitObjCImplementationAttr(ObjCImplementationAttr *attr) {
}
}
else if (auto AFD = dyn_cast<AbstractFunctionDecl>(D)) {
if (!hasObjCImplementationFeature(D, attr, Feature::CImplementation))
return;

if (!attr->CategoryName.empty()) {
auto diagnostic =
diagnose(attr->getLocation(),
Expand Down Expand Up @@ -2486,12 +2483,6 @@ void AttributeChecker::visitCDeclAttr(CDeclAttr *attr) {
if (D->getAttrs().getAttribute<ObjCAttr>()) {
diagnose(attr->getLocation(), diag::cdecl_incompatible_with_objc, D);
}

// @c needs to be enabled via a feature flag.
if (!attr->Underscored &&
!Ctx.LangOpts.hasFeature(Feature::CDecl)) {
diagnose(attr->getLocation(), diag::cdecl_feature_required);
}
}

void AttributeChecker::visitExposeAttr(ExposeAttr *attr) {
Expand Down
25 changes: 5 additions & 20 deletions lib/Sema/TypeCheckDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,11 @@ static void diagnoseTypeNotRepresentableInObjC(const DeclContext *DC,

// Special diagnostic for enums.
if (T->is<EnumType>()) {
if (DC->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
// New dialog mentioning @c.
diags.diagnose(TypeRange.Start, diag::not_cdecl_or_objc_swift_enum,
language)
.highlight(TypeRange)
.limitBehavior(behavior);
} else {
diags.diagnose(TypeRange.Start, diag::not_objc_swift_enum)
.highlight(TypeRange)
.limitBehavior(behavior);
}
// New dialog mentioning @c.
diags.diagnose(TypeRange.Start, diag::not_cdecl_or_objc_swift_enum,
language)
.highlight(TypeRange)
.limitBehavior(behavior);
return;
}

Expand Down Expand Up @@ -4193,15 +4187,6 @@ class ObjCImplementationChecker {
!decl->getASTContext().LangOpts.hasFeature(Feature::ObjCImplementation))
return;

if (isa<AbstractFunctionDecl>(decl) &&
!decl->getASTContext().LangOpts.hasFeature(Feature::CImplementation))
return;

// Only encourage @_objcImplementation *extension* adopters to adopt
// @implementation; @_objcImplementation @_cdecl hasn't been stabilized yet.
if (!isa<ExtensionDecl>(decl))
return;

auto diag = diagnose(getAttr()->getLocation(),
diag::objc_implementation_early_spelling_deprecated);
diag.fixItReplace(getAttr()->getRangeWithAt(), "@implementation");
Expand Down
4 changes: 0 additions & 4 deletions test/ASTGen/attrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// RUN: -enable-experimental-feature Extern \
// RUN: -enable-experimental-feature Lifetimes \
// RUN: -enable-experimental-feature RawLayout \
// RUN: -enable-experimental-feature CDecl \
// RUN: -enable-experimental-concurrency \
// RUN: -enable-experimental-move-only \
// RUN: -enable-experimental-feature ParserASTGen \
Expand All @@ -14,7 +13,6 @@
// RUN: -enable-experimental-feature Extern \
// RUN: -enable-experimental-feature Lifetimes \
// RUN: -enable-experimental-feature RawLayout \
// RUN: -enable-experimental-feature CDecl \
// RUN: -enable-experimental-concurrency \
// RUN: -enable-experimental-move-only \
// RUN: | %sanitize-address > %t/cpp-parser.ast
Expand All @@ -27,7 +25,6 @@
// RUN: -enable-experimental-feature Extern \
// RUN: -enable-experimental-feature Lifetimes \
// RUN: -enable-experimental-feature RawLayout \
// RUN: -enable-experimental-feature CDecl \
// RUN: -enable-experimental-concurrency \
// RUN: -enable-experimental-move-only

Expand All @@ -37,7 +34,6 @@
// REQUIRES: swift_feature_Extern
// REQUIRES: swift_feature_Lifetimes
// REQUIRES: swift_feature_RawLayout
// REQUIRES: swift_feature_CDecl

// rdar://116686158
// UNSUPPORTED: asan
Expand Down
5 changes: 0 additions & 5 deletions test/IRGen/cdecl_implementation.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \
// RUN: -enable-experimental-feature CImplementation \
// RUN: -enable-experimental-feature CDecl \
// RUN: -disable-objc-interop \
// RUN: -F %clang-importer-sdk-path/frameworks %s \
// RUN: -import-objc-header %S/Inputs/objc_implementation.h -emit-ir \
// RUN: -target %target-future-triple > %t.ir
// RUN: %FileCheck --input-file %t.ir %s

// REQUIRES: swift_feature_CImplementation
// REQUIRES: swift_feature_CDecl

@implementation @c
public func implFunc(_ param: Int32) {}

Expand Down
3 changes: 1 addition & 2 deletions test/IRGen/objc_implementation.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Test doesn't pass on all platforms (rdar://101420862)
// REQUIRES: OS=macosx

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature CImplementation -I %S/Inputs/abi -F %clang-importer-sdk-path/frameworks %s -import-objc-header %S/Inputs/objc_implementation.h -emit-ir -target %target-future-triple > %t.ir
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi -F %clang-importer-sdk-path/frameworks %s -import-objc-header %S/Inputs/objc_implementation.h -emit-ir -target %target-future-triple > %t.ir
// RUN: %FileCheck --input-file %t.ir %s
// RUN: %FileCheck --input-file %t.ir --check-prefix NEGATIVE %s
// REQUIRES: objc_interop
// REQUIRES: swift_feature_CImplementation

// CHECK-DAG: @"$sSo36ImplClassWithResilientStoredPropertyC19objc_implementationE9beforeInts5Int32VvpWvd" = hidden global i64 8, align 8
// CHECK-DAG: @"$sSo36ImplClassWithResilientStoredPropertyC19objc_implementationE6mirrors6MirrorVSgvpWvd" = hidden global i64 0, align 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public struct Strct {
public let transform2: ns.anonStructInNS
}

// CHECK: #if __has_feature(objc_modules)
// CHECK: #if __has_feature(objc_modules)
// CHECK: #if __has_feature(objc_modules)
// CHECK-NEXT: #if __has_warning("-Watimport-in-framework-header")
Expand Down
3 changes: 1 addition & 2 deletions test/Interpreter/cdecl_enum_run.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift(-enable-experimental-feature CDecl) > %t.out
// RUN: %target-run-simple-swift > %t.out
// RUN: %FileCheck --input-file %t.out %s

// REQUIRES: swift_feature_CDecl
// REQUIRES: executable_test

@c
Expand Down
6 changes: 1 addition & 5 deletions test/Interpreter/cdecl_implementation_run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// RUN: %target-build-swift-dylib(%t/%target-library-name(Lib)) %t/Lib.swift \
// RUN: -emit-module-path %t/Lib.swiftmodule \
// RUN: -emit-clang-header-path %t/cdecl.h \
// RUN: -import-objc-header %t/BridgingHeader.h \
// RUN: -enable-experimental-feature CDecl \
// RUN: -enable-experimental-feature CImplementation
// RUN: -import-objc-header %t/BridgingHeader.h
// RUN: %target-codesign %t/%target-library-name(Lib)

/// Build a C client against cdecl.h.
Expand All @@ -25,8 +23,6 @@
// RUN: %target-run %t/a.out %t/%target-library-name(Lib) > %t/run.log
// RUN: %FileCheck %t/Client.swift --check-prefix=PRINTS --input-file %t/run.log

// REQUIRES: swift_feature_CDecl
// REQUIRES: swift_feature_CImplementation
// REQUIRES: executable_test

//--- BridgingHeader.h
Expand Down
6 changes: 2 additions & 4 deletions test/Interpreter/cdecl_official_run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
// RUN: %t/Lib.swift -emit-module -verify -o %t -emit-module-doc \
// RUN: -emit-clang-header-path %t/cdecl.h \
// RUN: -disable-implicit-string-processing-module-import \
// RUN: -disable-implicit-concurrency-module-import \
// RUN: -enable-experimental-feature CDecl
// RUN: -disable-implicit-concurrency-module-import

/// Build and run a binary from Swift and C code.
// RUN: %clang-no-modules -c %t/Client.c -o %t/Client.o -target %target-triple \
// RUN: %target-pic-opt -I %t -I %clang-include-dir -Werror -isysroot %sdk
// RUN: %target-build-swift %t/Lib.swift %t/Client.o -O -o %t/a.out \
// RUN: -Xfrontend -disable-implicit-string-processing-module-import \
// RUN: -Xfrontend -disable-implicit-concurrency-module-import \
// RUN: -enable-experimental-feature CDecl -parse-as-library
// RUN: -parse-as-library
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out > %t/run.log
// RUN: %FileCheck %s --input-file %t/run.log

// REQUIRES: swift_feature_CDecl
// REQUIRES: executable_test

//--- Lib.swift
Expand Down
3 changes: 1 addition & 2 deletions test/Interpreter/objc_implementation.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D TOP_LEVEL_CODE -swift-version 5 -enable-experimental-feature CImplementation -target %target-stable-abi-triple) %s | %FileCheck %s
// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D TOP_LEVEL_CODE -swift-version 5 -target %target-stable-abi-triple) %s | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: swift_feature_CImplementation

import Foundation

Expand Down
3 changes: 1 addition & 2 deletions test/Interpreter/objc_implementation_objc_client.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// RUN: %empty-directory(%t/objc_implementation.framework/Headers)
// RUN: cp %S/Inputs/objc_implementation.modulemap %t/objc_implementation.framework/Modules/module.modulemap
// RUN: cp %S/Inputs/objc_implementation.h %t/objc_implementation.framework/Headers
// RUN: %target-build-swift-dylib(%t/objc_implementation.framework/objc_implementation) -emit-module-path %t/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t -import-underlying-module -Xlinker -install_name -Xlinker @executable_path/objc_implementation.framework/objc_implementation %S/objc_implementation.swift -enable-experimental-feature CImplementation -target %target-stable-abi-triple
// RUN: %target-build-swift-dylib(%t/objc_implementation.framework/objc_implementation) -emit-module-path %t/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t -import-underlying-module -Xlinker -install_name -Xlinker @executable_path/objc_implementation.framework/objc_implementation %S/objc_implementation.swift -target %target-stable-abi-triple

//
// Execute this file
Expand All @@ -22,7 +22,6 @@
// FIXME: This test fails in Swift CI simulators, but I have not been able to
// reproduce this locally.
// REQUIRES: OS=macosx
// REQUIRES: swift_feature_CImplementation

#import <Foundation/Foundation.h>
#import <objc_implementation/objc_implementation.h>
Expand Down
3 changes: 1 addition & 2 deletions test/Interpreter/objc_implementation_resilience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Will not execute correctly without ObjC runtime support.
// REQUIRES: rdar109171643

// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D RESILIENCE -swift-version 5 -enable-experimental-feature CImplementation -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple %S/objc_implementation.swift) | %FileCheck %S/objc_implementation.swift --check-prefixes CHECK,CHECK-RESILIENCE
// RUN: %target-run-simple-swift(-import-objc-header %S/Inputs/objc_implementation.h -D RESILIENCE -swift-version 5 -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple %S/objc_implementation.swift) | %FileCheck %S/objc_implementation.swift --check-prefixes CHECK,CHECK-RESILIENCE
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: swift_feature_CImplementation
// REQUIRES: swift_feature_ObjCImplementationWithResilientStorage

@main struct Main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// RUN: %empty-directory(%t-frameworks/objc_implementation.framework/Headers)
// RUN: cp %S/Inputs/objc_implementation.modulemap %t-frameworks/objc_implementation.framework/Modules/module.modulemap
// RUN: cp %S/Inputs/objc_implementation.h %t-frameworks/objc_implementation.framework/Headers
// RUN: %target-build-swift-dylib(%t-frameworks/objc_implementation.framework/objc_implementation) -emit-module-path %t-frameworks/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t-frameworks -import-underlying-module -Xlinker -install_name -Xlinker %t-frameworks/objc_implementation.framework/objc_implementation %S/objc_implementation.swift -D RESILIENCE -enable-experimental-feature CImplementation -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple
// RUN: %target-build-swift-dylib(%t-frameworks/objc_implementation.framework/objc_implementation) -emit-module-path %t-frameworks/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t-frameworks -import-underlying-module -Xlinker -install_name -Xlinker %t-frameworks/objc_implementation.framework/objc_implementation %S/objc_implementation.swift -D RESILIENCE -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple
//
// Execute this file
//
Expand All @@ -27,5 +27,4 @@
// FIXME: This test fails in Swift CI simulators, but I have not been able to
// reproduce this locally.
// REQUIRES: OS=macosx
// REQUIRES: swift_feature_CImplementation
// REQUIRES: swift_feature_ObjCImplementationWithResilientStorage
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// RUN: %empty-directory(%t/frameworks/objc_implementation.framework/Headers)
// RUN: cp %S/Inputs/objc_implementation.modulemap %t/frameworks/objc_implementation.framework/Modules/module.modulemap
// RUN: cp %S/Inputs/objc_implementation.h %t/frameworks/objc_implementation.framework/Headers
// RUN: %target-build-swift-dylib(%t/frameworks/objc_implementation.framework/objc_implementation) -D RESILIENCE -enable-experimental-feature CImplementation -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple -emit-module-path %t/frameworks/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t/frameworks -import-underlying-module -Xlinker -install_name -Xlinker %t/frameworks/objc_implementation.framework/objc_implementation %S/objc_implementation.swift
// RUN: %target-build-swift-dylib(%t/frameworks/objc_implementation.framework/objc_implementation) -D RESILIENCE -enable-experimental-feature ObjCImplementationWithResilientStorage -target %target-future-triple -emit-module-path %t/frameworks/objc_implementation.framework/Modules/objc_implementation.swiftmodule/%module-target-triple.swiftmodule -module-name objc_implementation -F %t/frameworks -import-underlying-module -Xlinker -install_name -Xlinker %t/frameworks/objc_implementation.framework/objc_implementation %S/objc_implementation.swift

//
// Execute this file
Expand All @@ -37,7 +37,6 @@

// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: swift_feature_CImplementation
// REQUIRES: swift_feature_ObjCImplementationWithResilientStorage

@main struct Main {
Expand Down
Loading