diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1480,22 +1480,6 @@ Targets[I.index()] = Env; } - // Do not allow conflicts with the watchOS target. - if (!Targets[Darwin::WatchOS].empty() && - (!Targets[Darwin::IPhoneOS].empty() || !Targets[Darwin::TvOS].empty())) { - TheDriver.Diag(diag::err_drv_conflicting_deployment_targets) - << "WATCHOS_DEPLOYMENT_TARGET" - << (!Targets[Darwin::IPhoneOS].empty() ? "IPHONEOS_DEPLOYMENT_TARGET" - : "TVOS_DEPLOYMENT_TARGET"); - } - - // Do not allow conflicts with the tvOS target. - if (!Targets[Darwin::TvOS].empty() && !Targets[Darwin::IPhoneOS].empty()) { - TheDriver.Diag(diag::err_drv_conflicting_deployment_targets) - << "TVOS_DEPLOYMENT_TARGET" - << "IPHONEOS_DEPLOYMENT_TARGET"; - } - // Allow conflicts among OSX and iOS for historical reasons, but choose the // default platform. if (!Targets[Darwin::MacOS].empty() && @@ -1508,6 +1492,18 @@ else Targets[Darwin::IPhoneOS] = Targets[Darwin::WatchOS] = Targets[Darwin::TvOS] = ""; + } else { + // Don't allow conflicts in any other platform. + int FirstTarget = llvm::array_lengthof(Targets); + for (int I = 0; I != llvm::array_lengthof(Targets); ++I) { + if (Targets[I].empty()) + continue; + if (FirstTarget == llvm::array_lengthof(Targets)) + FirstTarget = I; + else + TheDriver.Diag(diag::err_drv_conflicting_deployment_targets) + << Targets[FirstTarget] << Targets[I]; + } } for (const auto &Target : llvm::enumerate(llvm::makeArrayRef(Targets))) {