Merge branch 'master' into ca65_long_jsr_jmp_rts

This commit is contained in:
Bob Andrews
2023-02-24 19:25:32 +01:00
committed by GitHub
18 changed files with 262 additions and 60 deletions

View File

@@ -68,6 +68,7 @@ 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 LongJsrJmpRts = 0; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
/* Emulation features */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */

View File

@@ -70,6 +70,7 @@ 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 LongJsrJmpRts; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
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

@@ -306,7 +306,7 @@ void SegAlign (unsigned long Alignment, int FillVal)
ActiveSeg->Align = CombinedAlignment;
/* Output a warning for larger alignments if not suppressed */
if (CombinedAlignment >= LARGE_ALIGNMENT && !LargeAlignment) {
if (CombinedAlignment >= LARGE_ALIGNMENT && CombinedAlignment > ActiveSeg->Align && CombinedAlignment > Alignment && !LargeAlignment) {
Warning (0, "Combined alignment is suspiciously large (%lu)",
CombinedAlignment);
}

View File

@@ -570,7 +570,18 @@ void SymCheck (void)
/* Check for open scopes */
if (CurrentScope->Parent != 0) {
Error ("Local scope was not closed");
if (CurrentScope->Label) {
/* proc has a label indicating the line it was opened. */
LIError (&CurrentScope->Label->DefLines,
"Local proc '%s' was not closed",
GetString (CurrentScope->Name));
} else {
/* scope has no label to track a line number, uses end-of-document line instead.
** Anonymous scopes will reveal their internal automatic name.
*/
Error ("Local scope '%s' was not closed",
GetString (CurrentScope->Name));
}
}
/* First pass: Walk through all symbols, checking for undefined's and

View File

@@ -1153,6 +1153,8 @@ static unsigned Opt_a_toscmpbool (StackOpData* D, const char* BoolTransformer)
/* Save lhs into zeropage */
AddStoreLhsA (D);
/* AddStoreLhsA may have moved the OpIndex, recalculate insertion point to prevent label migration. */
D->IP = D->OpIndex + 1;
/* cmp */
X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPLo, 0, D->OpEntry->LI);
@@ -1206,6 +1208,8 @@ static unsigned Opt_a_tosicmp (StackOpData* D)
/* RHS src is not directly comparable */
X = NewCodeEntry (OP65_STA, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI);
InsertEntry (D, X, D->Rhs.A.ChgIndex + 1);
/* RHS insertion may have moved the OpIndex, recalculate insertion point to prevent label migration. */
D->IP = D->OpIndex + 1;
/* Cmp with stored RHS */
X = NewCodeEntry (OP65_CMP, AM65_ZP, D->ZPHi, 0, D->OpEntry->LI);

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

View File

@@ -230,7 +230,7 @@ Section* ReadSection (FILE* F, ObjData* O)
"%lu. Last module requiring alignment was '%s'.",
GetString (Name), Alignment, MAX_ALIGNMENT,
GetObjFileName (O));
} else if (Alignment >= LARGE_ALIGNMENT && !LargeAlignment) {
} else if (Alignment >= LARGE_ALIGNMENT && Alignment > S->Alignment && Alignment > Sec->Alignment && !LargeAlignment) {
Warning ("Combined alignment for segment '%s' is suspiciously "
"large (%lu). Last module requiring alignment was '%s'.",
GetString (Name), Alignment, GetObjFileName (O));