From c9f242e566f5a86c0bf4809aa5f1e2ddbc617b63 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 5 May 2021 14:42:29 +0200 Subject: [PATCH 01/12] Extend #pragma wrapped-call to support "bank" argument --- src/cc65/declare.c | 4 +++- src/cc65/expr.c | 13 ++++++++++--- src/cc65/funcdesc.h | 1 + src/cc65/pragma.c | 10 +++++++--- src/cc65/wrappedcall.c | 9 +++++---- src/cc65/wrappedcall.h | 4 ++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 0868c2082..0b705a320 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1739,6 +1739,7 @@ static FuncDesc* ParseFuncDecl (void) SymEntry* Sym; SymEntry* WrappedCall; unsigned char WrappedCallData; + int WrappedCallUseBank; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1791,10 +1792,11 @@ static FuncDesc* ParseFuncDecl (void) RememberFunctionLevel (F); /* Did we have a WrappedCall for this function? */ - GetWrappedCall((void **) &WrappedCall, &WrappedCallData); + GetWrappedCall((void **) &WrappedCall, &WrappedCallData, &WrappedCallUseBank); if (WrappedCall) { F->WrappedCall = WrappedCall; F->WrappedCallData = WrappedCallData; + F->WrappedCallUseBank = WrappedCallUseBank; } /* Return the function descriptor */ diff --git a/src/cc65/expr.c b/src/cc65/expr.c index bc277f13b..d2cd4ca5c 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -997,9 +997,16 @@ static void FunctionCall (ExprDesc* Expr) char tmp[64]; StrBuf S = AUTO_STRBUF_INITIALIZER; - /* Store the WrappedCall data in tmp4 */ - sprintf(tmp, "ldy #%u", Func->WrappedCallData); - SB_AppendStr (&S, tmp); + if (Func->WrappedCallUseBank) { + /* Store the bank attribute in tmp4 */ + SB_AppendStr (&S, "ldy #<.bank(_"); + SB_AppendStr (&S, (const char*) Expr->Name); + SB_AppendChar (&S, ')'); + } else { + /* Store the WrappedCall data in tmp4 */ + sprintf(tmp, "ldy #%u", Func->WrappedCallData); + SB_AppendStr (&S, tmp); + } g_asmcode (&S); SB_Clear(&S); diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 423e7621f..5875723fb 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -72,6 +72,7 @@ struct FuncDesc { struct FuncDesc* FuncDef; /* Descriptor used in definition */ struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ unsigned char WrappedCallData;/* The WrappedCall's user data */ + int WrappedCallUseBank;/* Flag: does WrappedCall use .bank() or literal value */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index f0f7ed36f..249e4f1b4 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -497,6 +497,7 @@ static void WrappedCallPragma (StrBuf* B) const char *Name; long Val; SymEntry *Entry; + int UseBank = 0; /* Check for the "push" or "pop" keywords */ switch (ParsePushPop (B)) { @@ -535,12 +536,15 @@ static void WrappedCallPragma (StrBuf* B) goto ExitPoint; } - if (!GetNumber (B, &Val)) { + /* Next must be either a numeric value, or "bank" */ + if (HasStr (B, "bank")) { + UseBank = 1; + } else if (!GetNumber (B, &Val)) { Error ("Value required for wrapped-call identifier"); goto ExitPoint; } - if (Val < 0 || Val > 255) { + if (!UseBank && (Val < 0 || Val > 255)) { Error ("Identifier must be between 0-255"); goto ExitPoint; } @@ -552,7 +556,7 @@ static void WrappedCallPragma (StrBuf* B) /* Check if the name is valid */ if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) { - PushWrappedCall(Entry, (unsigned char) Val); + PushWrappedCall(Entry, (unsigned char) Val, UseBank); Entry->Flags |= SC_REF; GetFuncDesc (Entry->Type)->Flags |= FD_CALL_WRAPPER; diff --git a/src/cc65/wrappedcall.c b/src/cc65/wrappedcall.c index 18cb507ac..a67f9815d 100644 --- a/src/cc65/wrappedcall.c +++ b/src/cc65/wrappedcall.c @@ -64,13 +64,13 @@ static IntPtrStack WrappedCalls; -void PushWrappedCall (void *Ptr, unsigned char Val) +void PushWrappedCall (void *Ptr, unsigned char Val, int UseBank) /* Push the current WrappedCall */ { if (IPS_IsFull (&WrappedCalls)) { Error ("WrappedCall stack overflow"); } else { - IPS_Push (&WrappedCalls, Val, Ptr); + IPS_Push (&WrappedCalls, Val | (UseBank << 8), Ptr); } } @@ -88,7 +88,7 @@ void PopWrappedCall (void) -void GetWrappedCall (void **Ptr, unsigned char *Val) +void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank) /* Get the current WrappedCall */ { if (IPS_GetCount (&WrappedCalls) < 1) { @@ -97,6 +97,7 @@ void GetWrappedCall (void **Ptr, unsigned char *Val) } else { long Temp; IPS_Get (&WrappedCalls, &Temp, Ptr); - *Val = (unsigned char) Temp; + *UseBank = (int) Temp >> 8; + *Val = (unsigned char) Temp & 0xff; } } diff --git a/src/cc65/wrappedcall.h b/src/cc65/wrappedcall.h index 3517c2465..ddf6dd2b9 100644 --- a/src/cc65/wrappedcall.h +++ b/src/cc65/wrappedcall.h @@ -50,13 +50,13 @@ -void PushWrappedCall (void *Ptr, unsigned char Val); +void PushWrappedCall (void *Ptr, unsigned char Val, int usebank); /* Push the current WrappedCall */ void PopWrappedCall (void); /* Pop the current WrappedCall */ -void GetWrappedCall (void **Ptr, unsigned char *Val); +void GetWrappedCall (void **Ptr, unsigned char *Val, int *usebank); /* Get the current WrappedCall, if any */ From 729690e9e97a9eefa06d744fb1762caa3351f548 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 5 May 2021 16:07:47 +0200 Subject: [PATCH 02/12] document the wrapped-call extension --- doc/cc65.sgml | 5 ++++- doc/ld65.sgml | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index dc754cb31..f4b31b8bc 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1388,7 +1388,10 @@ parameter with the operator will be used + to determine the number from the bank attribute defined in the linker config, + see . The address of a wrapped function is passed in Other MEMORY area attributes

+Other MEMORY area attributes

There are some other attributes not covered above. Before starting the reference section, I will discuss the remaining things here. @@ -822,7 +822,6 @@ that has a segment reference (for example a symbol). The result of this function is the value of the bank attribute for the run memory area of the segment. - Other SEGMENT attributes

Segments may be aligned to some memory boundary. Specify " Date: Tue, 11 May 2021 10:40:44 +0200 Subject: [PATCH 03/12] Just some source formatting adjustments. --- src/cc65/funcdesc.c | 16 ++++++++-------- src/cc65/funcdesc.h | 34 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index 4c959fb6c..2291b35ee 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -54,14 +54,14 @@ FuncDesc* NewFuncDesc (void) FuncDesc* F = (FuncDesc*) xmalloc (sizeof (FuncDesc)); /* Nullify the fields */ - F->Flags = 0; - F->SymTab = 0; - F->TagTab = 0; - F->ParamCount = 0; - F->ParamSize = 0; - F->LastParam = 0; - F->FuncDef = 0; - F->WrappedCall = 0; + F->Flags = 0; + F->SymTab = 0; + F->TagTab = 0; + F->ParamCount = 0; + F->ParamSize = 0; + F->LastParam = 0; + F->FuncDef = 0; + F->WrappedCall = 0; F->WrappedCallData = 0; /* Return the new struct */ diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 423e7621f..b69cfa850 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -45,15 +45,15 @@ /* Masks for the Flags field in FuncDesc */ -#define FD_NONE 0x0000U /* No flags */ -#define FD_EMPTY 0x0001U /* Function with empty param list */ -#define FD_VOID_PARAM 0x0002U /* Function with a void param list */ -#define FD_VARIADIC 0x0004U /* Function with variable param list */ +#define FD_NONE 0x0000U /* No flags */ +#define FD_EMPTY 0x0001U /* Function with empty param list */ +#define FD_VOID_PARAM 0x0002U /* Function with a void param list */ +#define FD_VARIADIC 0x0004U /* Function with variable param list */ #define FD_INCOMPLETE_PARAM 0x0008U /* Function with param of unknown size */ -#define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ -#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ -#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ -#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ +#define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ +#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ +#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ +#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ /* Bits that must be ignored when comparing funcs */ #define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) @@ -63,15 +63,15 @@ /* Function descriptor */ typedef struct FuncDesc FuncDesc; struct FuncDesc { - unsigned Flags; /* Bitmapped flags FD_... */ - struct SymTable* SymTab; /* Symbol table */ - struct SymTable* TagTab; /* Symbol table for structs/enums */ - unsigned ParamCount; /* Number of parameters */ - unsigned ParamSize; /* Size of the parameters */ - struct SymEntry* LastParam; /* Pointer to last parameter */ - struct FuncDesc* FuncDef; /* Descriptor used in definition */ - struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ - unsigned char WrappedCallData;/* The WrappedCall's user data */ + unsigned Flags; /* Bitmapped flags FD_... */ + struct SymTable* SymTab; /* Symbol table */ + struct SymTable* TagTab; /* Symbol table for structs/enums */ + unsigned ParamCount; /* Number of parameters */ + unsigned ParamSize; /* Size of the parameters */ + struct SymEntry* LastParam; /* Pointer to last parameter */ + struct FuncDesc* FuncDef; /* Descriptor used in definition */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned char WrappedCallData; /* The WrappedCall's user data */ }; From ef8c70c7affb4c423af17fcc87a2308ad4284a46 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 11 May 2021 13:36:30 +0200 Subject: [PATCH 04/12] use url instead of htmlurl, add note on least significant 8bits of the bank value --- doc/cc65.sgml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index f4b31b8bc..7912b85a9 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1389,9 +1389,11 @@ parameter with the operator will be used + is "bank", then a operator will be used to determine the number from the bank attribute defined in the linker config, - see . + see . Note that + this currently implies that only the least significant 8 bits of the bank attribute + can be used. The address of a wrapped function is passed in Date: Tue, 11 May 2021 13:37:53 +0200 Subject: [PATCH 05/12] improve error message --- src/cc65/pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 249e4f1b4..84869e60f 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -532,7 +532,7 @@ static void WrappedCallPragma (StrBuf* B) /* Skip the following comma */ if (!GetComma (B)) { /* Error already flagged by GetComma */ - Error ("Value required for wrapped-call identifier"); + Error ("Value or the word 'bank' required for wrapped-call identifier"); goto ExitPoint; } From 18f94d1fe0b2b04c723419a4df9078f77c88c0a0 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 11 May 2021 14:00:49 +0200 Subject: [PATCH 06/12] rework to use a magic value instead of a flag, as suggested by Oliver --- src/cc65/declare.c | 6 ++---- src/cc65/expr.c | 2 +- src/cc65/funcdesc.h | 5 ++--- src/cc65/pragma.c | 7 +++---- src/cc65/wrappedcall.c | 9 ++++----- src/cc65/wrappedcall.h | 4 ++-- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 0b705a320..8879c46d8 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1738,8 +1738,7 @@ static FuncDesc* ParseFuncDecl (void) { SymEntry* Sym; SymEntry* WrappedCall; - unsigned char WrappedCallData; - int WrappedCallUseBank; + unsigned int WrappedCallData; /* Create a new function descriptor */ FuncDesc* F = NewFuncDesc (); @@ -1792,11 +1791,10 @@ static FuncDesc* ParseFuncDecl (void) RememberFunctionLevel (F); /* Did we have a WrappedCall for this function? */ - GetWrappedCall((void **) &WrappedCall, &WrappedCallData, &WrappedCallUseBank); + GetWrappedCall((void **) &WrappedCall, &WrappedCallData); if (WrappedCall) { F->WrappedCall = WrappedCall; F->WrappedCallData = WrappedCallData; - F->WrappedCallUseBank = WrappedCallUseBank; } /* Return the function descriptor */ diff --git a/src/cc65/expr.c b/src/cc65/expr.c index d2cd4ca5c..01bebf18e 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -997,7 +997,7 @@ static void FunctionCall (ExprDesc* Expr) char tmp[64]; StrBuf S = AUTO_STRBUF_INITIALIZER; - if (Func->WrappedCallUseBank) { + if (Func->WrappedCallData == WRAPPED_CALL_USE_BANK) { /* Store the bank attribute in tmp4 */ SB_AppendStr (&S, "ldy #<.bank(_"); SB_AppendStr (&S, (const char*) Expr->Name); diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 5875723fb..305fd14f5 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -58,7 +58,7 @@ /* Bits that must be ignored when comparing funcs */ #define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) - +#define WRAPPED_CALL_USE_BANK 0x0100U /* WrappedCall uses .bank() */ /* Function descriptor */ typedef struct FuncDesc FuncDesc; @@ -71,8 +71,7 @@ struct FuncDesc { struct SymEntry* LastParam; /* Pointer to last parameter */ struct FuncDesc* FuncDef; /* Descriptor used in definition */ struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ - unsigned char WrappedCallData;/* The WrappedCall's user data */ - int WrappedCallUseBank;/* Flag: does WrappedCall use .bank() or literal value */ + unsigned int WrappedCallData;/* The WrappedCall's user data */ }; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 84869e60f..e4bb4cdeb 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -497,7 +497,6 @@ static void WrappedCallPragma (StrBuf* B) const char *Name; long Val; SymEntry *Entry; - int UseBank = 0; /* Check for the "push" or "pop" keywords */ switch (ParsePushPop (B)) { @@ -538,13 +537,13 @@ static void WrappedCallPragma (StrBuf* B) /* Next must be either a numeric value, or "bank" */ if (HasStr (B, "bank")) { - UseBank = 1; + Val = WRAPPED_CALL_USE_BANK; } else if (!GetNumber (B, &Val)) { Error ("Value required for wrapped-call identifier"); goto ExitPoint; } - if (!UseBank && (Val < 0 || Val > 255)) { + if (!(Val == WRAPPED_CALL_USE_BANK) && (Val < 0 || Val > 255)) { Error ("Identifier must be between 0-255"); goto ExitPoint; } @@ -556,7 +555,7 @@ static void WrappedCallPragma (StrBuf* B) /* Check if the name is valid */ if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) { - PushWrappedCall(Entry, (unsigned char) Val, UseBank); + PushWrappedCall(Entry, (unsigned int) Val); Entry->Flags |= SC_REF; GetFuncDesc (Entry->Type)->Flags |= FD_CALL_WRAPPER; diff --git a/src/cc65/wrappedcall.c b/src/cc65/wrappedcall.c index a67f9815d..ecf2c3a53 100644 --- a/src/cc65/wrappedcall.c +++ b/src/cc65/wrappedcall.c @@ -64,13 +64,13 @@ static IntPtrStack WrappedCalls; -void PushWrappedCall (void *Ptr, unsigned char Val, int UseBank) +void PushWrappedCall (void *Ptr, unsigned int Val) /* Push the current WrappedCall */ { if (IPS_IsFull (&WrappedCalls)) { Error ("WrappedCall stack overflow"); } else { - IPS_Push (&WrappedCalls, Val | (UseBank << 8), Ptr); + IPS_Push (&WrappedCalls, Val, Ptr); } } @@ -88,7 +88,7 @@ void PopWrappedCall (void) -void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank) +void GetWrappedCall (void **Ptr, unsigned int *Val) /* Get the current WrappedCall */ { if (IPS_GetCount (&WrappedCalls) < 1) { @@ -97,7 +97,6 @@ void GetWrappedCall (void **Ptr, unsigned char *Val, int *UseBank) } else { long Temp; IPS_Get (&WrappedCalls, &Temp, Ptr); - *UseBank = (int) Temp >> 8; - *Val = (unsigned char) Temp & 0xff; + *Val = (unsigned int) Temp; } } diff --git a/src/cc65/wrappedcall.h b/src/cc65/wrappedcall.h index ddf6dd2b9..9a1bb51bf 100644 --- a/src/cc65/wrappedcall.h +++ b/src/cc65/wrappedcall.h @@ -50,13 +50,13 @@ -void PushWrappedCall (void *Ptr, unsigned char Val, int usebank); +void PushWrappedCall (void *Ptr, unsigned int Val); /* Push the current WrappedCall */ void PopWrappedCall (void); /* Pop the current WrappedCall */ -void GetWrappedCall (void **Ptr, unsigned char *Val, int *usebank); +void GetWrappedCall (void **Ptr, unsigned int *Val); /* Get the current WrappedCall, if any */ From 07dd1e3849672f8c1487ef652611f745a96a90da Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 11 May 2021 14:14:44 +0200 Subject: [PATCH 07/12] fix formatting --- src/cc65/funcdesc.c | 16 ++++++++-------- src/cc65/funcdesc.h | 34 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cc65/funcdesc.c b/src/cc65/funcdesc.c index 4c959fb6c..2291b35ee 100644 --- a/src/cc65/funcdesc.c +++ b/src/cc65/funcdesc.c @@ -54,14 +54,14 @@ FuncDesc* NewFuncDesc (void) FuncDesc* F = (FuncDesc*) xmalloc (sizeof (FuncDesc)); /* Nullify the fields */ - F->Flags = 0; - F->SymTab = 0; - F->TagTab = 0; - F->ParamCount = 0; - F->ParamSize = 0; - F->LastParam = 0; - F->FuncDef = 0; - F->WrappedCall = 0; + F->Flags = 0; + F->SymTab = 0; + F->TagTab = 0; + F->ParamCount = 0; + F->ParamSize = 0; + F->LastParam = 0; + F->FuncDef = 0; + F->WrappedCall = 0; F->WrappedCallData = 0; /* Return the new struct */ diff --git a/src/cc65/funcdesc.h b/src/cc65/funcdesc.h index 305fd14f5..e065c7602 100644 --- a/src/cc65/funcdesc.h +++ b/src/cc65/funcdesc.h @@ -45,15 +45,15 @@ /* Masks for the Flags field in FuncDesc */ -#define FD_NONE 0x0000U /* No flags */ -#define FD_EMPTY 0x0001U /* Function with empty param list */ -#define FD_VOID_PARAM 0x0002U /* Function with a void param list */ -#define FD_VARIADIC 0x0004U /* Function with variable param list */ +#define FD_NONE 0x0000U /* No flags */ +#define FD_EMPTY 0x0001U /* Function with empty param list */ +#define FD_VOID_PARAM 0x0002U /* Function with a void param list */ +#define FD_VARIADIC 0x0004U /* Function with variable param list */ #define FD_INCOMPLETE_PARAM 0x0008U /* Function with param of unknown size */ -#define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ -#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ -#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ -#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ +#define FD_OLDSTYLE 0x0010U /* Old style (K&R) function */ +#define FD_OLDSTYLE_INTRET 0x0020U /* K&R func has implicit int return */ +#define FD_UNNAMED_PARAMS 0x0040U /* Function has unnamed params */ +#define FD_CALL_WRAPPER 0x0080U /* This function is used as a wrapper */ /* Bits that must be ignored when comparing funcs */ #define FD_IGNORE (FD_INCOMPLETE_PARAM | FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER) @@ -63,15 +63,15 @@ /* Function descriptor */ typedef struct FuncDesc FuncDesc; struct FuncDesc { - unsigned Flags; /* Bitmapped flags FD_... */ - struct SymTable* SymTab; /* Symbol table */ - struct SymTable* TagTab; /* Symbol table for structs/enums */ - unsigned ParamCount; /* Number of parameters */ - unsigned ParamSize; /* Size of the parameters */ - struct SymEntry* LastParam; /* Pointer to last parameter */ - struct FuncDesc* FuncDef; /* Descriptor used in definition */ - struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ - unsigned int WrappedCallData;/* The WrappedCall's user data */ + unsigned Flags; /* Bitmapped flags FD_... */ + struct SymTable* SymTab; /* Symbol table */ + struct SymTable* TagTab; /* Symbol table for structs/enums */ + unsigned ParamCount; /* Number of parameters */ + unsigned ParamSize; /* Size of the parameters */ + struct SymEntry* LastParam; /* Pointer to last parameter */ + struct FuncDesc* FuncDef; /* Descriptor used in definition */ + struct SymEntry* WrappedCall; /* Pointer to the WrappedCall */ + unsigned int WrappedCallData; /* The WrappedCall's user data */ }; From bcc670ee36ac00155e6a763f97eb3791ab9d0ddc Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Mon, 10 May 2021 09:56:40 +0100 Subject: [PATCH 08/12] Standard formatting of error messages. https://www.gnu.org/prep/standards/html_node/Errors.html Issue: https://github.com/cc65/cc65/issues/1494 --- src/ca65/error.c | 2 +- src/cc65/error.c | 8 ++++---- src/cc65/pragma.c | 2 +- src/cc65/preproc.c | 2 +- src/da65/asminc.c | 8 ++++---- src/da65/scanner.c | 4 ++-- src/ld65/asserts.c | 4 ++-- src/ld65/exports.c | 8 +++++--- src/ld65/scanner.c | 4 ++-- 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/ca65/error.c b/src/ca65/error.c index 69446b3fc..7e1457964 100644 --- a/src/ca65/error.c +++ b/src/ca65/error.c @@ -84,7 +84,7 @@ static void VPrintMsg (const FilePos* Pos, const char* Desc, SB_Terminate (&Msg); /* Format the message header */ - SB_Printf (&S, "%s(%u): %s: ", + SB_Printf (&S, "%s:%u: %s: ", SB_GetConstBuf (GetFileName (Pos->Name)), Pos->Line, Desc); diff --git a/src/cc65/error.c b/src/cc65/error.c index b1529d0b5..f0e023969 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -129,7 +129,7 @@ void Fatal (const char* Format, ...) LineNum = GetCurrentLine (); } - fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum); + fprintf (stderr, "%s:%u: Fatal: ", FileName, LineNum); va_start (ap, Format); vfprintf (stderr, Format, ap); @@ -159,7 +159,7 @@ void Internal (const char* Format, ...) LineNum = GetCurrentLine (); } - fprintf (stderr, "%s(%u): Internal compiler error:\n", + fprintf (stderr, "%s:%u: Internal compiler error:\n", FileName, LineNum); va_start (ap, Format); @@ -186,7 +186,7 @@ void Internal (const char* Format, ...) static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va_list ap) /* Print an error message - internal function*/ { - fprintf (stderr, "%s(%u): Error: ", Filename, LineNo); + fprintf (stderr, "%s:%u: Error: ", Filename, LineNo); vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); @@ -250,7 +250,7 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg, } else if (IS_Get (&WarnEnable)) { - fprintf (stderr, "%s(%u): Warning: ", Filename, LineNo); + fprintf (stderr, "%s:%u: Warning: ", Filename, LineNo); vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index e4bb4cdeb..b0478ce2a 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -784,7 +784,7 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High) static void MakeMessage (const char* Message) { - fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message); + fprintf (stderr, "%s:%u: Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message); } diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index cc160c1c3..37073e784 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -1396,7 +1396,7 @@ void Preprocess (void) Done: if (Verbosity > 1 && SB_NotEmpty (Line)) { - printf ("%s(%u): %.*s\n", GetCurrentFile (), GetCurrentLine (), + printf ("%s:%u: %.*s\n", GetCurrentFile (), GetCurrentLine (), (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } } diff --git a/src/da65/asminc.c b/src/da65/asminc.c index 59ba0aab4..4d9da2594 100644 --- a/src/da65/asminc.c +++ b/src/da65/asminc.c @@ -133,7 +133,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) SB_Terminate (&Ident); } else { if (!IgnoreUnknown) { - Error ("%s(%u): Syntax error", Filename, Line); + Error ("%s:%u: Syntax error", Filename, Line); } continue; } @@ -148,7 +148,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) ++L; } else { if (!IgnoreUnknown) { - Error ("%s(%u): Missing '='", Filename, Line); + Error ("%s:%u: Missing '='", Filename, Line); } continue; } @@ -192,7 +192,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) /* Must have at least one digit */ if (Digits == 0) { if (!IgnoreUnknown) { - Error ("%s(%u): Error in number format", Filename, Line); + Error ("%s:%u: Error in number format", Filename, Line); } continue; } @@ -213,7 +213,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) /* Check for a comment character or end of line */ if (*L != CommentStart && *L != '\0') { if (!IgnoreUnknown) { - Error ("%s(%u): Trailing garbage", Filename, Line); + Error ("%s:%u: Trailing garbage", Filename, Line); } continue; } diff --git a/src/da65/scanner.c b/src/da65/scanner.c index 85853d6c4..33fb3a826 100644 --- a/src/da65/scanner.c +++ b/src/da65/scanner.c @@ -94,7 +94,7 @@ void InfoWarning (const char* Format, ...) xvsprintf (Buf, sizeof (Buf), Format, ap); va_end (ap); - fprintf (stderr, "%s(%u): Warning: %s\n", + fprintf (stderr, "%s:%u: Warning: %s\n", InputSrcName, InfoErrorLine, Buf); } @@ -110,7 +110,7 @@ void InfoError (const char* Format, ...) xvsprintf (Buf, sizeof (Buf), Format, ap); va_end (ap); - fprintf (stderr, "%s(%u): Error: %s\n", + fprintf (stderr, "%s:%u: Error: %s\n", InputSrcName, InfoErrorLine, Buf); exit (EXIT_FAILURE); } diff --git a/src/ld65/asserts.c b/src/ld65/asserts.c index 626ed94a6..e9bae83e5 100644 --- a/src/ld65/asserts.c +++ b/src/ld65/asserts.c @@ -140,12 +140,12 @@ void CheckAssertions (void) case ASSERT_ACT_WARN: case ASSERT_ACT_LDWARN: - Warning ("%s(%u): %s", Module, Line, Message); + Warning ("%s:%u: %s", Module, Line, Message); break; case ASSERT_ACT_ERROR: case ASSERT_ACT_LDERROR: - Error ("%s(%u): %s", Module, Line, Message); + Error ("%s:%u: %s", Module, Line, Message); break; default: diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 5df7a37c9..872db5143 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -774,17 +774,19 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data) if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) { /* Unresolved external */ Import* Imp = E->ImpList; + const char * name = GetString (E->Name); fprintf (stderr, "Unresolved external '%s' referenced in:\n", - GetString (E->Name)); + name); while (Imp) { unsigned J; for (J = 0; J < CollCount (&Imp->RefLines); ++J) { const LineInfo* LI = CollConstAt (&Imp->RefLines, J); fprintf (stderr, - " %s(%u)\n", + " %s:%u: Error: Unresolved external '%s'\n", GetSourceName (LI), - GetSourceLine (LI)); + GetSourceLine (LI), + name); } Imp = Imp->Next; } diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index d6278abbd..256d47f07 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -92,7 +92,7 @@ void CfgWarning (const FilePos* Pos, const char* Format, ...) SB_VPrintf (&Buf, Format, ap); va_end (ap); - Warning ("%s(%u): %s", + Warning ("%s:%u: %s", GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); SB_Done (&Buf); } @@ -109,7 +109,7 @@ void CfgError (const FilePos* Pos, const char* Format, ...) SB_VPrintf (&Buf, Format, ap); va_end (ap); - Error ("%s(%u): %s", + Error ("%s:%u: %s", GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); SB_Done (&Buf); } From 467844963a7207afd8857d93caf7c6daa74901ce Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Mon, 10 May 2021 10:35:17 +0100 Subject: [PATCH 09/12] Update failing test due to error format changes. --- test/misc/goto.ref | 300 ++++++++++++++++++++++----------------------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/test/misc/goto.ref b/test/misc/goto.ref index d0a978436..2e0819887 100644 --- a/test/misc/goto.ref +++ b/test/misc/goto.ref @@ -1,150 +1,150 @@ -goto.c(8): Warning: Goto at line 8 to label start jumps into a block with initialization of an object that has automatic storage duration -goto.c(97): Warning: Variable 'a' is defined but never used -goto.c(117): Warning: Variable 'a' is defined but never used -goto.c(137): Warning: Variable 'a' is defined but never used -goto.c(159): Warning: Goto at line 23 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 44 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 65 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 86 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 106 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 126 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(159): Warning: Goto at line 146 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 24 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 45 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 66 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 87 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 107 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 127 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 147 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(180): Warning: Goto at line 168 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 25 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 46 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 67 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 88 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 108 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 128 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 148 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 169 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(201): Warning: Goto at line 190 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 26 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 47 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 68 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 89 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 109 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 129 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 149 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(221): Warning: Goto at line 170 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(231): Warning: Goto at line 231 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 27 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 48 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 69 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 90 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 110 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 130 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(241): Warning: Goto at line 150 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(250): Warning: Goto at line 250 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(251): Warning: Goto at line 251 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(252): Warning: Goto at line 252 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 28 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 49 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 70 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 91 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 111 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 131 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 151 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 172 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 193 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 214 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 234 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(263): Warning: Goto at line 254 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(271): Warning: Goto at line 271 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(272): Warning: Goto at line 272 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(273): Warning: Goto at line 273 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(274): Warning: Goto at line 274 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(275): Warning: Goto at line 275 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 29 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 50 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 71 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 92 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 112 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 132 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 152 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 173 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 194 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 215 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 235 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 255 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(284): Warning: Goto at line 277 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(292): Warning: Goto at line 292 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(293): Warning: Goto at line 293 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(294): Warning: Goto at line 294 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(295): Warning: Goto at line 295 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(296): Warning: Goto at line 296 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 30 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 51 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 72 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 93 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 113 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 133 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 153 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 174 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 195 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 216 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 236 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 256 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 278 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(305): Warning: Goto at line 299 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(313): Warning: Goto at line 313 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(314): Warning: Goto at line 314 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(315): Warning: Goto at line 315 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(316): Warning: Goto at line 316 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(317): Warning: Goto at line 317 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 31 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 52 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 73 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 94 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 114 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 134 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 154 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 175 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 196 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 217 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 237 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 257 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(325): Warning: Goto at line 279 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(333): Warning: Goto at line 333 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(334): Warning: Goto at line 334 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(335): Warning: Goto at line 335 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(336): Warning: Goto at line 336 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(337): Warning: Goto at line 337 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(340): Warning: Goto at line 340 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 32 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 53 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 74 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 95 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 115 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 135 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 155 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 176 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 197 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 218 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 238 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(345): Warning: Goto at line 258 to label lh jumps into a block with initialization of an object that has automatic storage duration -goto.c(353): Warning: Goto at line 353 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(354): Warning: Goto at line 354 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(355): Warning: Goto at line 355 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(356): Warning: Goto at line 356 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(357): Warning: Goto at line 357 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(359): Warning: Goto at line 359 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(360): Warning: Goto at line 360 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(361): Warning: Goto at line 361 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(373): Warning: Goto at line 373 to label l8 jumps into a block with initialization of an object that has automatic storage duration -goto.c(374): Warning: Goto at line 374 to label l9 jumps into a block with initialization of an object that has automatic storage duration -goto.c(375): Warning: Goto at line 375 to label la jumps into a block with initialization of an object that has automatic storage duration -goto.c(376): Warning: Goto at line 376 to label lb jumps into a block with initialization of an object that has automatic storage duration -goto.c(377): Warning: Goto at line 377 to label lc jumps into a block with initialization of an object that has automatic storage duration -goto.c(378): Warning: Goto at line 378 to label ld jumps into a block with initialization of an object that has automatic storage duration -goto.c(379): Warning: Goto at line 379 to label le jumps into a block with initialization of an object that has automatic storage duration -goto.c(380): Warning: Goto at line 380 to label lf jumps into a block with initialization of an object that has automatic storage duration -goto.c(381): Warning: Goto at line 381 to label lg jumps into a block with initialization of an object that has automatic storage duration -goto.c(382): Warning: Goto at line 382 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:8: Warning: Goto at line 8 to label start jumps into a block with initialization of an object that has automatic storage duration +goto.c:97: Warning: Variable 'a' is defined but never used +goto.c:117: Warning: Variable 'a' is defined but never used +goto.c:137: Warning: Variable 'a' is defined but never used +goto.c:159: Warning: Goto at line 23 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 44 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 65 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 86 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 106 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 126 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:159: Warning: Goto at line 146 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 24 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 45 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 66 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 87 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 107 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 127 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 147 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:180: Warning: Goto at line 168 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 25 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 46 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 67 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 88 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 108 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 128 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 148 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 169 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:201: Warning: Goto at line 190 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 26 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 47 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 68 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 89 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 109 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 129 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 149 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:221: Warning: Goto at line 170 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:231: Warning: Goto at line 231 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 27 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 48 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 69 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 90 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 110 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 130 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:241: Warning: Goto at line 150 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:250: Warning: Goto at line 250 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:251: Warning: Goto at line 251 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:252: Warning: Goto at line 252 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 28 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 49 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 70 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 91 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 111 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 131 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 151 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 172 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 193 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 214 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 234 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:263: Warning: Goto at line 254 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:271: Warning: Goto at line 271 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:272: Warning: Goto at line 272 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:273: Warning: Goto at line 273 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:274: Warning: Goto at line 274 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:275: Warning: Goto at line 275 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 29 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 50 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 71 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 92 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 112 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 132 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 152 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 173 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 194 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 215 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 235 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 255 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:284: Warning: Goto at line 277 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:292: Warning: Goto at line 292 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:293: Warning: Goto at line 293 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:294: Warning: Goto at line 294 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:295: Warning: Goto at line 295 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:296: Warning: Goto at line 296 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 30 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 51 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 72 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 93 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 113 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 133 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 153 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 174 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 195 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 216 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 236 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 256 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 278 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:305: Warning: Goto at line 299 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:313: Warning: Goto at line 313 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:314: Warning: Goto at line 314 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:315: Warning: Goto at line 315 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:316: Warning: Goto at line 316 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:317: Warning: Goto at line 317 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 31 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 52 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 73 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 94 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 114 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 134 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 154 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 175 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 196 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 217 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 237 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 257 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:325: Warning: Goto at line 279 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:333: Warning: Goto at line 333 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:334: Warning: Goto at line 334 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:335: Warning: Goto at line 335 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:336: Warning: Goto at line 336 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:337: Warning: Goto at line 337 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:340: Warning: Goto at line 340 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 32 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 53 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 74 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 95 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 115 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 135 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 155 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 176 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 197 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 218 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 238 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:345: Warning: Goto at line 258 to label lh jumps into a block with initialization of an object that has automatic storage duration +goto.c:353: Warning: Goto at line 353 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:354: Warning: Goto at line 354 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:355: Warning: Goto at line 355 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:356: Warning: Goto at line 356 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:357: Warning: Goto at line 357 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:359: Warning: Goto at line 359 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:360: Warning: Goto at line 360 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:361: Warning: Goto at line 361 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:373: Warning: Goto at line 373 to label l8 jumps into a block with initialization of an object that has automatic storage duration +goto.c:374: Warning: Goto at line 374 to label l9 jumps into a block with initialization of an object that has automatic storage duration +goto.c:375: Warning: Goto at line 375 to label la jumps into a block with initialization of an object that has automatic storage duration +goto.c:376: Warning: Goto at line 376 to label lb jumps into a block with initialization of an object that has automatic storage duration +goto.c:377: Warning: Goto at line 377 to label lc jumps into a block with initialization of an object that has automatic storage duration +goto.c:378: Warning: Goto at line 378 to label ld jumps into a block with initialization of an object that has automatic storage duration +goto.c:379: Warning: Goto at line 379 to label le jumps into a block with initialization of an object that has automatic storage duration +goto.c:380: Warning: Goto at line 380 to label lf jumps into a block with initialization of an object that has automatic storage duration +goto.c:381: Warning: Goto at line 381 to label lg jumps into a block with initialization of an object that has automatic storage duration +goto.c:382: Warning: Goto at line 382 to label lh jumps into a block with initialization of an object that has automatic storage duration From feccc68c547c7f74d6202db179181fdf31e3f946 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Tue, 11 May 2021 13:54:05 +0100 Subject: [PATCH 10/12] ld65: avoid redundant error message information. --- src/ld65/exports.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 872db5143..6580033fb 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -774,16 +774,13 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data) if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) { /* Unresolved external */ Import* Imp = E->ImpList; - const char * name = GetString (E->Name); - fprintf (stderr, - "Unresolved external '%s' referenced in:\n", - name); + const char* name = GetString (E->Name); while (Imp) { unsigned J; for (J = 0; J < CollCount (&Imp->RefLines); ++J) { const LineInfo* LI = CollConstAt (&Imp->RefLines, J); fprintf (stderr, - " %s:%u: Error: Unresolved external '%s'\n", + "%s:%u: Error: Unresolved external '%s'\n", GetSourceName (LI), GetSourceLine (LI), name); From 93762a2117760b97391c26f8f926a2a69cf921e5 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Tue, 11 May 2021 13:54:36 +0100 Subject: [PATCH 11/12] ld65: move 2 more cases to the notation file:line. --- src/ld65/exports.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 6580033fb..bb66ab2ce 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -166,7 +166,7 @@ Import* ReadImport (FILE* F, ObjData* Obj) */ if (ObjHasFiles (I->Obj)) { const LineInfo* LI = GetImportPos (I); - Error ("Invalid import size in for '%s', imported from %s(%u): 0x%02X", + Error ("Invalid import size in for '%s', imported from %s:%u: 0x%02X", GetString (I->Name), GetSourceName (LI), GetSourceLine (LI), @@ -1057,7 +1057,7 @@ void CircularRefError (const Export* E) /* Print an error about a circular reference using to define the given export */ { const LineInfo* LI = GetExportPos (E); - Error ("Circular reference for symbol '%s', %s(%u)", + Error ("Circular reference for symbol '%s', %s:%u", GetString (E->Name), GetSourceName (LI), GetSourceLine (LI)); From 05f545e18924a5fdea21d0d25b5462013847b2bd Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Tue, 11 May 2021 16:32:43 +0100 Subject: [PATCH 12/12] More line number related changes. --- libsrc/common/_afailed.c | 2 +- src/ld65/exports.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/common/_afailed.c b/libsrc/common/_afailed.c index ad50a8750..ab8b94ca6 100644 --- a/libsrc/common/_afailed.c +++ b/libsrc/common/_afailed.c @@ -15,6 +15,6 @@ void __fastcall__ _afailed (char* file, unsigned line) { raise (SIGABRT); - fprintf (stderr, "ASSERTION FAILED IN %s(%u)\n", file, line); + fprintf (stderr, "ASSERTION FAILED IN %s:%u\n", file, line); exit (EXIT_ASSERT); } diff --git a/src/ld65/exports.c b/src/ld65/exports.c index bb66ab2ce..35de5c8f2 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -690,12 +690,12 @@ static void CheckSymType (const Export* E) */ if (E->Obj) { /* The export comes from an object file */ - SB_Printf (&ExportLoc, "%s, %s(%u)", + SB_Printf (&ExportLoc, "%s, %s:%u", GetString (E->Obj->Name), GetSourceName (ExportLI), GetSourceLine (ExportLI)); } else if (ExportLI) { - SB_Printf (&ExportLoc, "%s(%u)", + SB_Printf (&ExportLoc, "%s:%u", GetSourceName (ExportLI), GetSourceLine (ExportLI)); } else { @@ -706,7 +706,7 @@ static void CheckSymType (const Export* E) } if (I->Obj) { /* The import comes from an object file */ - SB_Printf (&ImportLoc, "%s, %s(%u)", + SB_Printf (&ImportLoc, "%s, %s:%u", GetString (I->Obj->Name), GetSourceName (ImportLI), GetSourceLine (ImportLI)); @@ -714,7 +714,7 @@ static void CheckSymType (const Export* E) /* The import is linker generated and we have line ** information */ - SB_Printf (&ImportLoc, "%s(%u)", + SB_Printf (&ImportLoc, "%s:%u", GetSourceName (ImportLI), GetSourceLine (ImportLI)); } else { @@ -995,7 +995,7 @@ void PrintImportMap (FILE* F) const LineInfo* LI = GetImportPos (Imp); if (LI) { fprintf (F, - " %-25s %s(%u)\n", + " %-25s %s:%u\n", GetObjFileName (Imp->Obj), GetSourceName (LI), GetSourceLine (LI));