mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] compilations that do not enable C++ interoperability should not be able to import modules that do enable C++ interoperability by default
A supplemental hidden frontend option allows advanced users to opt-out of this requirement. Fixes https://github.com/apple/swift/issues/65833 Fixes https://github.com/apple/swift/issues/65832
This commit is contained in:
@@ -824,6 +824,8 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
|
||||
M.setABIName(Ctx.getIdentifier(loadedModuleFile->getModuleABIName()));
|
||||
if (loadedModuleFile->isConcurrencyChecked())
|
||||
M.setIsConcurrencyChecked();
|
||||
if (loadedModuleFile->hasCxxInteroperability())
|
||||
M.setHasCxxInteroperability();
|
||||
if (!loadedModuleFile->getModulePackageName().empty()) {
|
||||
M.setPackageName(Ctx.getIdentifier(loadedModuleFile->getModulePackageName()));
|
||||
}
|
||||
@@ -896,6 +898,19 @@ LoadedFile *SerializedModuleLoaderBase::loadAST(
|
||||
diag::need_hermetic_seal_to_import_module, M.getName());
|
||||
}
|
||||
|
||||
// Non-resilient modules built with C++ interoperability enabled
|
||||
// are typically incompatible with clients that do not enable
|
||||
// C++ interoperability.
|
||||
if (M.hasCxxInteroperability() &&
|
||||
M.getResilienceStrategy() != ResilienceStrategy::Resilient &&
|
||||
!Ctx.LangOpts.EnableCXXInterop &&
|
||||
Ctx.LangOpts.RequireCxxInteropToImportCxxInteropModule) {
|
||||
auto loc = diagLoc.value_or(SourceLoc());
|
||||
Ctx.Diags.diagnose(loc, diag::need_cxx_interop_to_import_module,
|
||||
M.getName());
|
||||
Ctx.Diags.diagnose(loc, diag::enable_cxx_interop_docs);
|
||||
}
|
||||
|
||||
return fileUnit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user