diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index d6a9e36ecbf8b..286570a3011cf 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -355,8 +355,6 @@ namespace swift { return CXXStdlib == PlatformDefaultCXXStdlib; } - bool CForeignReferenceTypes = false; - /// Imports getters and setters as computed properties. bool CxxInteropGettersSettersAsProperties = false; diff --git a/include/swift/Option/Options.td b/include/swift/Option/Options.td index a9dadc790250d..e1474d7e8e271 100644 --- a/include/swift/Option/Options.td +++ b/include/swift/Option/Options.td @@ -867,7 +867,7 @@ def cxx_interoperability_mode : def experimental_c_foreign_reference_types : Flag<["-"], "experimental-c-foreign-reference-types">, Flags<[FrontendOption, HelpHidden, ModuleInterfaceOption]>, - HelpText<"Enable experimental C foreign references types (with reference counting).">; + HelpText<"Enable experimental C foreign references types. Deprecated, has no effect.">; def experimental_hermetic_seal_at_link: Flag<["-"], "experimental-hermetic-seal-at-link">, diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index a9c4dc521804f..520b335209180 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -169,10 +169,6 @@ void ClangImporter::Implementation::makeComputed(AbstractStorageDecl *storage, bool importer::recordHasReferenceSemantics( const clang::RecordDecl *decl, ClangImporter::Implementation *importerImpl) { - if (!isa(decl) && - !importerImpl->SwiftContext.LangOpts.CForeignReferenceTypes) - return false; - // At this point decl might not be fully imported into Swift yet, which // means we might not have asked Clang to generate its implicit members, such // as copy or move constructors. This would cause CxxRecordSemanticsRequest to diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index afbf32fdbb1a4..1d3453640dfff 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1580,8 +1580,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Args.hasFlag(OPT_enable_objc_interop, OPT_disable_objc_interop, Target.isOSDarwin() && !Opts.hasFeature(Feature::Embedded)); - Opts.CForeignReferenceTypes = - Args.hasArg(OPT_experimental_c_foreign_reference_types); + if (Args.hasArg(OPT_experimental_c_foreign_reference_types)) + Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated, + "-experimental-c-foreign-reference-types"); Opts.CxxInteropGettersSettersAsProperties = Args.hasArg(OPT_cxx_interop_getters_setters_as_properties); Opts.RequireCxxInteropToImportCxxInteropModule = diff --git a/test/Interop/C/struct/foreign-reference-flag-deprecated.swift b/test/Interop/C/struct/foreign-reference-flag-deprecated.swift new file mode 100644 index 0000000000000..7c9398e51bdd2 --- /dev/null +++ b/test/Interop/C/struct/foreign-reference-flag-deprecated.swift @@ -0,0 +1,5 @@ +// RUN: %target-build-swift %s -I %S/Inputs/ -Xfrontend -experimental-c-foreign-reference-types 2>&1 | %FileCheck %s + +// CHECK: :0: warning: flag '-experimental-c-foreign-reference-types' is deprecated + +import ForeignReference diff --git a/test/Interop/C/struct/foreign-reference.swift b/test/Interop/C/struct/foreign-reference.swift index 43680cd995f1f..a73c3d330b21e 100644 --- a/test/Interop/C/struct/foreign-reference.swift +++ b/test/Interop/C/struct/foreign-reference.swift @@ -1,9 +1,10 @@ -// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Xfrontend -experimental-c-foreign-reference-types -Onone -D NO_OPTIMIZATIONS) -// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Xfrontend -experimental-c-foreign-reference-types -O) +// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Onone -D NO_OPTIMIZATIONS) +// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -O) // // REQUIRES: executable_test -// TODO: This should work without ObjC interop in the future rdar://97497120 -// REQUIRES: objc_interop + +// XFAIL: OS=windows-msvc +// FIXME: Runtime support for C++ foreign reference types is missing on Windows (https://github.com/swiftlang/swift/issues/82643) import StdlibUnittest import ForeignReference