--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

@@ -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;
}