Skip to content

Commit 3f5f55a

Browse files
authored
Merge pull request #706 from slavapestov/unavailable-enum-case-warning
Pass -warn-on-potentially-unavailable-enum-case frontend flag when building a module
2 parents f32e8e1 + 3ebf8b4 commit 3f5f55a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ extension Driver {
8585
commandLine.appendFlag("-aarch64-use-tbi")
8686
}
8787

88+
// Potentially unavailable enum cases are downgraded to a warning when building a
89+
// swiftmodule, to allow building a module (or module interface) for an older
90+
// deployment target than the framework itself.
91+
if isFrontendArgSupported(.warnOnPotentiallyUnavailableEnumCase) {
92+
if compilerOutputType == .swiftModule {
93+
commandLine.appendFlag(.warnOnPotentiallyUnavailableEnumCase)
94+
}
95+
}
96+
8897
// Enable or disable ObjC interop appropriately for the platform
8998
if targetTriple.isDarwin {
9099
commandLine.appendFlag(.enableObjcInterop)

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ extension Option {
576576
public static let warnLongExpressionTypeChecking: Option = Option("-warn-long-expression-type-checking", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<n>", helpText: "Warns when type-checking a function takes longer than <n> ms")
577577
public static let warnLongFunctionBodiesEQ: Option = Option("-warn-long-function-bodies=", .joined, alias: Option.warnLongFunctionBodies, attributes: [.helpHidden, .frontend, .noDriver])
578578
public static let warnLongFunctionBodies: Option = Option("-warn-long-function-bodies", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<n>", helpText: "Warns when type-checking a function takes longer than <n> ms")
579+
public static let warnOnPotentiallyUnavailableEnumCase: Option = Option("-warn-on-potentially-unavailable-enum-case", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Downgrade potential unavailability of enum case to a warning")
579580
public static let warnSwift3ObjcInferenceComplete: Option = Option("-warn-swift3-objc-inference-complete", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Warn about deprecated @objc inference in Swift 3 for every declaration that will no longer be inferred as @objc in Swift 4")
580581
public static let warnSwift3ObjcInferenceMinimal: Option = Option("-warn-swift3-objc-inference-minimal", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Warn about deprecated @objc inference in Swift 3 based on direct uses of the Objective-C entrypoint")
581582
public static let warnSwift3ObjcInference: Option = Option("-warn-swift3-objc-inference", .flag, alias: Option.warnSwift3ObjcInferenceComplete, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild])

0 commit comments

Comments
 (0)