Add a --warnings-as-errors option to cc65 for compatibility reasons.

This commit is contained in:
Kugel Fuhr
2025-07-14 11:35:53 +02:00
parent 2e4c18770b
commit 170ddc6e33
4 changed files with 33 additions and 1 deletions

View File

@@ -110,6 +110,7 @@ Long options:
--target sys Set the target system
--verbose Increase verbosity
--version Print the compiler version number
--warnings-as-errors Treat warnings as errors
--writable-strings Make string literals writable
---------------------------------------------------------------------------
</verb></tscreen>
@@ -656,6 +657,15 @@ Here is a description of all the command line options:
or warnings are encountered.
<label id="option--warnings-as-errors">
<tag><tt>--warnings-as-errors</tt></tag>
Treat all warnings as error. This makes the compiler exit with an appropriate
error code in case of warnings. The effect of this switch is identical to
the command line option <tt/<ref id="option-W" name="-W error">/. It is
available for compatibility with the other tools.
<label id="option-writable-strings">
<tag><tt>--writable-strings</tt></tag>
@@ -766,7 +776,9 @@ Here is a description of all the command line options:
<tag><tt/const-comparison/</tag>
Warn if the result of a comparison is constant.
<tag><tt/error/</tag>
Treat all warnings as errors.
Treat all warnings as errors. This has the same effect as using the
<tt/<ref id="option--warnings-as-errors" name="--warnings-as-errors">/
option.
<tag><tt/no-effect/</tag>
Warn about statements that don't have an effect.
<tag><tt/pointer-sign/</tag>

View File

@@ -742,6 +742,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
exit (EXIT_SUCCESS);
}
static void OptSeglist (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Enable segment listing */
@@ -749,6 +751,8 @@ static void OptSeglist (const char* Opt attribute ((unused)),
SegList = 1;
}
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Generate an error if any warnings occur */
@@ -756,6 +760,8 @@ static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
WarningsAsErrors = 1;
}
static void OptExpandMacros (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Expand macros in listing
@@ -767,6 +773,8 @@ static void OptExpandMacros (const char* Opt attribute ((unused)),
ExpandMacros++;
}
static void DoPCAssign (void)
/* Start absolute code */
{

View File

@@ -140,6 +140,7 @@ static void Usage (void)
" --target sys\t\t\tSet the target system\n"
" --verbose\t\t\tIncrease verbosity\n"
" --version\t\t\tPrint the compiler version number\n"
" --warnings-as-errors\t\tTreat warnings as errors\n"
" --writable-strings\t\tMake string literals writable\n",
ProgName);
}
@@ -968,6 +969,15 @@ static void OptWarning (const char* Opt attribute ((unused)), const char* Arg)
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Generate an error if any warnings occur */
{
IS_Set (&WarningsAreErrors, 1);
}
static void OptWritableStrings (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Make string literals writable */
@@ -1016,6 +1026,7 @@ int main (int argc, char* argv[])
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--warnings-as-errors", 0, OptWarningsAsErrors },
{ "--writable-strings", 0, OptWritableStrings },
};

View File

@@ -1441,6 +1441,7 @@ static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
/* Handle the --warnings-as-errors option */
{
CmdAddArg (&CA65, "--warnings-as-errors");
CmdAddArg (&CC65, "--warnings-as-errors");
CmdAddArg (&LD65, "--warnings-as-errors");
}