1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-02 00:41:40 +00:00

Allow enabling/disabling warnings individually

This commit is contained in:
Karol Stasiak 2021-02-24 03:04:53 +01:00
parent 3155d7a571
commit ffa0ffb899
4 changed files with 101 additions and 8 deletions

View File

@ -278,3 +278,37 @@ By default, the compiler emits only some of the most important warnings.
* `-Wnone` Disable all warnings.
* `-Wfatal` Treat warnings as errors.
You can also enable or disable warnings individually:
* `-Wbuggy`, `-Wno-buggy`
Whether should warn about code that may cause surprising behaviours or even miscompilation.
Default: enabled.
* `-Wdeprecation`, `-Wno-deprecation`
Whether should warn about deprecated aliases.
Default: enabled.
* `-Wextra-comparisons`, `-Wno-extra-comparisons`
Whether should warn about simplifiable unsigned integer comparisons.
Default: disabled.
* `-Wfallback`, `-Wno-fallback`
Whether should warn about the use of default values by text codecs, the preprocessor, and array literals.
Default: enabled.
* `-Wmissing-output`, `-Wno-missing-output`
Whether should warn about data that is missing in output files.
Default: enabled.
* `-Woverlapping-call`, `-Wno-overlapping-call`
Whether should warn about calls to functions in a different, yet overlapping segment.
Default: enabled.
* `-Wror`, `-Wno-ror`
Whether should warn about the ROR instruction (6502 only).
Default: disabled.
* `-Wuseless`, `-Wno-useless`
Whether should warn about code that does nothing.
Default: enabled.

View File

@ -413,8 +413,20 @@ object Cpu extends Enumeration {
import CompilationFlag._
private val alwaysDefaultFlags = Set(
VariableOverlap, CompactReturnDispatchParams, FunctionFallthrough, RegisterVariables, FunctionDeduplication, EnableBreakpoints,
GenericWarnings, UselessCodeWarning, BuggyCodeWarning, FallbackValueUseWarning, DeprecationWarning, NonZeroTerminatedLiteralWarning, CallToOverlappingBankWarning,
VariableOverlap,
CompactReturnDispatchParams,
FunctionFallthrough,
RegisterVariables,
FunctionDeduplication,
EnableBreakpoints,
GenericWarnings,
UselessCodeWarning,
BuggyCodeWarning,
FallbackValueUseWarning,
DeprecationWarning,
NonZeroTerminatedLiteralWarning,
CallToOverlappingBankWarning,
DataMissingInOutputWarning,
)
private val mosAlwaysDefaultFlags = alwaysDefaultFlags
@ -578,12 +590,23 @@ object CompilationFlag extends Enumeration {
RorWarning,
NonZeroTerminatedLiteralWarning,
CallToOverlappingBankWarning,
DataMissingInOutputWarning,
FatalWarnings,
// special options for internal compiler use
EnableInternalTestSyntax,
InternalCurrentlyOptimizingForMeasurement = Value
val allWarnings: Set[CompilationFlag.Value] = Set(GenericWarnings, UselessCodeWarning, BuggyCodeWarning, DeprecationWarning, FallbackValueUseWarning, ExtraComparisonWarnings, NonZeroTerminatedLiteralWarning, CallToOverlappingBankWarning)
val allWarnings: Set[CompilationFlag.Value] = Set(
GenericWarnings,
UselessCodeWarning,
BuggyCodeWarning,
DeprecationWarning,
FallbackValueUseWarning,
ExtraComparisonWarnings,
NonZeroTerminatedLiteralWarning,
CallToOverlappingBankWarning,
DataMissingInOutputWarning,
)
val fromString: Map[String, CompilationFlag.Value] = Map(
"lunix" -> LUnixRelocatableCode,

View File

@ -781,6 +781,40 @@ object Main {
c.changeFlag(CompilationFlag.FatalWarnings, true)
}.description("Treat warnings as errors.")
fluff("", "Specific warning options:", "")
boolean("-Wbuggy", "-Wno-buggy").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.BuggyCodeWarning, v)
}.description("Whether should warn about code that may cause surprising behaviours or even miscompilation. Default: enabled.")
boolean("-Wdeprecation", "-Wno-deprecation").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.DeprecationWarning, v)
}.description("Whether should warn about deprecated aliases. Default: enabled.")
boolean("-Wextra-comparisons", "-Wno-extra-comparisons").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.ExtraComparisonWarnings, v)
}.description("Whether should warn about simplifiable unsigned integer comparisons. Default: disabled.")
boolean("-Wfallback", "-Wno-fallback").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.FallbackValueUseWarning, v)
}.description("Whether should warn about the use of default values by text codecs, the preprocessor, and array literals. Default: enabled.")
boolean("-Wmissing-output", "-Wno-missing-output").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.DataMissingInOutputWarning, v)
}.description("Whether should warn about data that is missing in output files. Default: enabled.")
boolean("-Woverlapping-call", "-Wno-overlapping-call").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.CallToOverlappingBankWarning, v)
}.description("Whether should warn about calls to functions in a different, yet overlapping segment. Default: enabled.")
boolean("-Wror", "-Wno-ror").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.RorWarning, v)
}.description("Whether should warn about the ROR instruction (6502 only). Default: disabled.")
boolean("-Wuseless", "-Wno-useless").repeatable().action { (c, v) =>
c.changeFlag(CompilationFlag.UselessCodeWarning, v)
}.description("Whether should warn about code that does nothing. Default: enabled.")
fluff("", "Other options:", "")
expansion("-Xd")("-O1", "-s", "-fsource-in-asm", "-g").description("Do a debug build. Equivalent to -O1 -s -fsource-in-asm -g")

View File

@ -718,11 +718,13 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
val outputPackager = platform.outputPackagers.getOrElse(b, platform.defaultOutputPackager)
b -> outputPackager.packageOutput(mem, b)
}.toMap
for (bank <- mem.banks.keys.toSeq.sorted) {
val missing = mem.banks(bank).initializedNotOutputted
if (missing.nonEmpty) {
val missingFormatted = MathUtils.collapseConsecutiveInts(missing, i => f"$$$i%04x")
log.warn(s"Fragments of segment ${bank} are not contained in any output: $missingFormatted")
if (options.flag(CompilationFlag.DataMissingInOutputWarning)) {
for (bank <- mem.banks.keys.toSeq.sorted) {
val missing = mem.banks(bank).initializedNotOutputted
if (missing.nonEmpty) {
val missingFormatted = MathUtils.collapseConsecutiveInts(missing, i => f"$$$i%04x")
log.warn(s"Fragments of segment ${bank} are not contained in any output: $missingFormatted")
}
}
}
AssemblerOutput(code, assembly.toArray, labelMap.toList, breakpointSet.toList.sorted)