@@ -682,7 +682,8 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
682682}
683683
684684void LangOptions::setCxxInteropFromArgs (ArgList &Args,
685- swift::DiagnosticEngine &Diags) {
685+ swift::DiagnosticEngine &Diags,
686+ const FrontendOptions &FrontendOpts) {
686687 if (Arg *A = Args.getLastArg (options::OPT_cxx_interoperability_mode)) {
687688 if (Args.hasArg (options::OPT_enable_experimental_cxx_interop)) {
688689 Diags.diagnose (SourceLoc (), diag::dont_enable_interop_and_compat);
@@ -737,7 +738,12 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
737738 // version, and is either 4, 5, 6, or 7 (even though only 5.9 and 6.* make
738739 // any sense). For now, we don't actually care about the version, so we'll
739740 // just use version 6 (i.e., 'swift-6') to mean that C++ interop mode is on.
740- if (EnableCXXInterop)
741+ //
742+ // FIXME: We always declare the 'Darwin' module as formally having been built
743+ // without C++Interop, for compatibility with prior versions. Once we are certain
744+ // that we are only building against modules built with support of
745+ // '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
746+ if (EnableCXXInterop && (FrontendOpts.ModuleName .compare (" Darwin" ) != 0 ))
741747 FormalCxxInteropMode = {6 };
742748 else
743749 FormalCxxInteropMode = std::nullopt ;
@@ -1560,7 +1566,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15601566 if (const Arg *A = Args.getLastArg (OPT_clang_target_variant))
15611567 Opts.ClangTargetVariant = llvm::Triple (A->getValue ());
15621568
1563- Opts.setCxxInteropFromArgs (Args, Diags);
1569+ Opts.setCxxInteropFromArgs (Args, Diags, FrontendOpts );
15641570 if (!Args.hasArg (options::OPT_formal_cxx_interoperability_mode))
15651571 ModuleInterfaceOpts.PublicFlags .IgnorableFlags +=
15661572 " " + printFormalCxxInteropVersion (Opts);
0 commit comments