1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

--warnings-as-errors for ca65 and ld65

This commit is contained in:
bbbradsmith 2023-02-20 22:24:26 -05:00
parent d0f17ba602
commit 45d0d60349
11 changed files with 119 additions and 43 deletions

View File

@ -125,6 +125,7 @@ Long options:
--target sys Set the target system
--verbose Increase verbosity
--version Print the assembler version
--warnings-as-errors Treat warnings as errors
---------------------------------------------------------------------------
</verb></tscreen>
@ -359,6 +360,13 @@ Here is a description of all the command line options:
warning level is 1, and it would probably be silly to set it to
something lower.
<label id="option--warnings-as-errors">
<tag><tt>--warnings-as-errors</tt></tag>
An error will be generated if any warnings were produced.
</descrip>
<p>

View File

@ -90,6 +90,7 @@ Long options:
--start-group Start a library group
--target sys Set the target system
--version Print the linker version
--warnings-as-errors Treat warnings as errors
---------------------------------------------------------------------------
</verb></tscreen>
@ -330,6 +331,13 @@ Here is a description of all of the command-line options:
directory, in the list of directories specified using <tt/--obj-path/, in
directories given by environment variables, and in a built-in default directory.
<label id="option--warnings-as-errors">
<tag><tt>--warnings-as-errors</tt></tag>
An error will be generated if any warnings were produced.
</descrip>

View File

@ -67,6 +67,7 @@ unsigned char LineCont = 0; /* Allow line continuation */
unsigned char LargeAlignment = 0; /* Don't warn about large alignments */
unsigned char RelaxChecks = 0; /* Relax a few assembler checks */
unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
/* Emulation features */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */

View File

@ -69,6 +69,7 @@ extern unsigned char LineCont; /* Allow line continuation */
extern unsigned char LargeAlignment; /* Don't warn about large alignments */
extern unsigned char RelaxChecks; /* Relax a few assembler checks */
extern unsigned char StringEscapes; /* Allow C-style escapes in strings */
extern unsigned char WarningsAsErrors; /* Error if any warnings */
/* Emulation features */
extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */

View File

@ -656,6 +656,15 @@ static void OptVersion (const char* Opt attribute ((unused)),
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Generate an error if any warnings occur */
{
WarningsAsErrors = 1;
}
static void DoPCAssign (void)
/* Start absolute code */
{
@ -919,27 +928,28 @@ int main (int argc, char* argv [])
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--auto-import", 0, OptAutoImport },
{ "--bin-include-dir", 1, OptBinIncludeDir },
{ "--cpu", 1, OptCPU },
{ "--create-dep", 1, OptCreateDep },
{ "--create-full-dep", 1, OptCreateFullDep },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--feature", 1, OptFeature },
{ "--help", 0, OptHelp },
{ "--ignore-case", 0, OptIgnoreCase },
{ "--include-dir", 1, OptIncludeDir },
{ "--large-alignment", 0, OptLargeAlignment },
{ "--list-bytes", 1, OptListBytes },
{ "--listing", 1, OptListing },
{ "--memory-model", 1, OptMemoryModel },
{ "--pagelength", 1, OptPageLength },
{ "--relax-checks", 0, OptRelaxChecks },
{ "--smart", 0, OptSmart },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--auto-import", 0, OptAutoImport },
{ "--bin-include-dir", 1, OptBinIncludeDir },
{ "--cpu", 1, OptCPU },
{ "--create-dep", 1, OptCreateDep },
{ "--create-full-dep", 1, OptCreateFullDep },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--feature", 1, OptFeature },
{ "--help", 0, OptHelp },
{ "--ignore-case", 0, OptIgnoreCase },
{ "--include-dir", 1, OptIncludeDir },
{ "--large-alignment", 0, OptLargeAlignment },
{ "--list-bytes", 1, OptListBytes },
{ "--listing", 1, OptListing },
{ "--memory-model", 1, OptMemoryModel },
{ "--pagelength", 1, OptPageLength },
{ "--relax-checks", 0, OptRelaxChecks },
{ "--smart", 0, OptSmart },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
{ "--warnings-as-errors", 0, OptWarningsAsErrors },
};
/* Name of the global name space */
@ -1144,6 +1154,10 @@ int main (int argc, char* argv [])
SegDump ();
}
if (WarningCount > 0 && WarningsAsErrors) {
Error("Warnings as errors");
}
/* If we didn't have an errors, finish off the line infos */
DoneLineInfo ();

View File

@ -46,6 +46,17 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Statistics */
unsigned WarningCount = 0;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
@ -66,6 +77,9 @@ void Warning (const char* Format, ...)
fprintf (stderr, "%s: Warning: %s\n", ProgName, SB_GetConstBuf (&S));
SB_Done (&S);
/* Count warnings */
++WarningCount;
}

View File

@ -43,6 +43,17 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Statistics */
extern unsigned WarningCount;
/*****************************************************************************/
/* Code */
/*****************************************************************************/

View File

@ -43,19 +43,20 @@
const char* OutputName = "a.out"; /* Name of output file */
unsigned OutputNameUsed = 0; /* Output name was used by %O */
const char* OutputName = "a.out"; /* Name of output file */
unsigned OutputNameUsed = 0; /* Output name was used by %O */
unsigned ModuleId = 0; /* Id for o65 module */
unsigned ModuleId = 0; /* Id for o65 module */
/* Start address */
unsigned char HaveStartAddr = 0; /* Start address not given */
unsigned long StartAddr = 0x200; /* Start address */
unsigned char HaveStartAddr = 0; /* Start address not given */
unsigned long StartAddr = 0x200; /* Start address */
unsigned char VerboseMap = 0; /* Verbose map file */
unsigned char AllowMultDef = 0; /* Allow multiple definitions */
unsigned char LargeAlignment = 0; /* Don't warn about large alignments */
unsigned char VerboseMap = 0; /* Verbose map file */
unsigned char AllowMultDef = 0; /* Allow multiple definitions */
unsigned char LargeAlignment = 0; /* Don't warn about large alignments */
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
const char* MapFileName = 0; /* Name of the map file */
const char* LabelFileName = 0; /* Name of the label file */
const char* DbgFileName = 0; /* Name of the debug file */
const char* MapFileName = 0; /* Name of the map file */
const char* LabelFileName = 0; /* Name of the label file */
const char* DbgFileName = 0; /* Name of the debug file */

View File

@ -44,21 +44,22 @@
extern const char* OutputName; /* Name of output file */
extern unsigned OutputNameUsed; /* Output name was used by %O */
extern const char* OutputName; /* Name of output file */
extern unsigned OutputNameUsed; /* Output name was used by %O */
extern unsigned ModuleId; /* Id for o65 module */
extern unsigned ModuleId; /* Id for o65 module */
extern unsigned char HaveStartAddr; /* True if start address was given */
extern unsigned long StartAddr; /* Start address */
extern unsigned char HaveStartAddr; /* True if start address was given */
extern unsigned long StartAddr; /* Start address */
extern unsigned char VerboseMap; /* Verbose map file */
extern unsigned char AllowMultDef; /* Allow multiple definitions */
extern unsigned char LargeAlignment; /* Don't warn about large alignments */
extern unsigned char VerboseMap; /* Verbose map file */
extern unsigned char AllowMultDef; /* Allow multiple definitions */
extern unsigned char LargeAlignment; /* Don't warn about large alignments */
extern unsigned char WarningsAsErrors; /* Error if any warnings */
extern const char* MapFileName; /* Name of the map file */
extern const char* LabelFileName; /* Name of the label file */
extern const char* DbgFileName; /* Name of the debug file */
extern const char* MapFileName; /* Name of the map file */
extern const char* LabelFileName; /* Name of the label file */
extern const char* DbgFileName; /* Name of the debug file */

View File

@ -559,6 +559,15 @@ static void OptVersion (const char* Opt attribute ((unused)),
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Generate an error if any warnings occur */
{
WarningsAsErrors = 1;
}
static void OptMultDef (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Set flag to allow multiple definitions of a global symbol */
@ -637,6 +646,7 @@ static void ParseCommandLine(void)
{ "--start-group", 0, CmdlOptStartGroup },
{ "--target", 1, CmdlOptTarget },
{ "--version", 0, OptVersion },
{ "--warnings-as-errors", 0, OptWarningsAsErrors },
};
unsigned I;
@ -845,6 +855,10 @@ int main (int argc, char* argv [])
(MemoryAreaOverflows > 1) ? 's' : ' ');
}
if (WarningCount > 0 && WarningsAsErrors) {
Error("Warnings as errors");
}
/* Create the output file */
CfgWriteTarget ();

View File

@ -95,6 +95,9 @@ void CfgWarning (const FilePos* Pos, const char* Format, ...)
Warning ("%s:%u: %s",
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
SB_Done (&Buf);
/* Count warnings */
++WarningCount;
}