From 5d198d6842c5183ed03f25e517e74607b1f9b4ec Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 12 May 2021 05:05:39 -0400 Subject: [PATCH 1/6] Fixed some URL links in a couple of documents. --- doc/cc65.sgml | 4 ++-- doc/funcref.sgml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 56a87ae72..004061518 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -1391,9 +1391,9 @@ parameter with the operator will be used + is "bank", then ca65's function will be used to determine the number from the bank attribute defined in the linker config, - see . Note that + see . Note that this currently implies that only the least significant 8 bits of the bank attribute can be used. diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 3b3db2e09..4d1a278b0 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -5186,7 +5186,7 @@ the module just loaded. Possible error codes are: -The linker is needed to create +The is needed to create relocatable o65 modules for use with this function. The function is available only as a fastcall function; so, it may be used only in the presence of a prototype. From af4c4f6aaf8e2eb93249d6fa9418cc5d62c87ad9 Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 12 May 2021 19:43:32 -0400 Subject: [PATCH 2/6] Removed a "return" keyword from an inline function that must return (void). --- src/cc65/codeent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc65/codeent.h b/src/cc65/codeent.h index bd542cc4c..ee1dd0220 100644 --- a/src/cc65/codeent.h +++ b/src/cc65/codeent.h @@ -184,7 +184,7 @@ INLINE CodeLabel* CE_GetLabel (CodeEntry* E, unsigned Index) INLINE void CE_ReplaceLabel (CodeEntry* E, CodeLabel* L, unsigned Index) /* Replace the code label at the specified index with L */ { - return CollReplace (&E->Labels, L, Index); + CollReplace (&E->Labels, L, Index); } #else # define CE_ReplaceLabel(E, L, Index) CollReplace (&(E)->Labels, (L), (Index)) From e5813cfb1ab7069c063d0a1a8a9fd14e58a3a1a9 Mon Sep 17 00:00:00 2001 From: Greg King Date: Thu, 13 May 2021 00:24:32 -0400 Subject: [PATCH 3/6] Removed two duplicate TYPEDEFs from a header. The first one is replaced by an #include of the header that has its original TYPEDEF. The second one is replaced by its base type. That change allows pedantic C90-compliant compilers to accept the header. --- src/cc65/codeoptutil.c | 2 +- src/cc65/datatype.c | 4 ++-- src/cc65/datatype.h | 24 +++++++++++------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/cc65/codeoptutil.c b/src/cc65/codeoptutil.c index 23c759fd1..16c41162a 100644 --- a/src/cc65/codeoptutil.c +++ b/src/cc65/codeoptutil.c @@ -1447,7 +1447,7 @@ void AdjustEntryIndices (Collection* Indices, int Index, int Change) } else if (Index <= *IndexPtr) { /* Has been removed */ *IndexPtr = -1; - //CollDelete (Indices, I); + /*CollDelete (Indices, I);*/ --I; } } diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index 9e52027ce..90bf892ba 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -1242,7 +1242,7 @@ const Type* GetBaseElementType (const Type* T) -SymEntry* GetESUSymEntry (const Type* T) +struct SymEntry* GetESUSymEntry (const Type* T) /* Return a SymEntry pointer from an enum/struct/union type */ { /* Only enums, structs or unions have a SymEntry attribute */ @@ -1254,7 +1254,7 @@ SymEntry* GetESUSymEntry (const Type* T) -void SetESUSymEntry (Type* T, SymEntry* S) +void SetESUSymEntry (Type* T, struct SymEntry* S) /* Set the SymEntry pointer for an enum/struct/union type */ { /* Only enums, structs or unions have a SymEntry attribute */ diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index 1140ee498..af1c6b8e4 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -45,6 +45,9 @@ #include "inline.h" #include "mmodel.h" +/* cc65 */ +#include "funcdesc.h" + /*****************************************************************************/ @@ -53,8 +56,8 @@ -typedef struct FuncDesc FuncDesc; -typedef struct SymEntry SymEntry; +struct StrBuf; +struct SymEntry; @@ -162,12 +165,12 @@ typedef unsigned long TypeCode; /* Type entry */ typedef struct Type Type; struct Type { - TypeCode C; /* Code for this entry */ + TypeCode C; /* Code for this entry */ union { - FuncDesc* F; /* Function description pointer */ - SymEntry* S; /* Enum/struct/union tag symbol entry pointer */ - long L; /* Numeric attribute value */ - unsigned long U; /* Dito, unsigned */ + struct FuncDesc* F; /* Function description pointer */ + struct SymEntry* S; /* Enum/struct/union tag symbol entry pointer */ + long L; /* Numeric attribute value */ + unsigned long U; /* Dito, unsigned */ } A; /* Type attribute if necessary */ }; @@ -221,11 +224,6 @@ extern const Type type_c_char_p[]; extern const Type type_void_p[]; extern const Type type_c_void_p[]; -/* Forward for the SymEntry struct */ -struct SymEntry; - -/* Forward for the StrBuf struct */ -struct StrBuf; /*****************************************************************************/ @@ -849,7 +847,7 @@ int IsVariadicFunc (const Type* T) attribute ((const)); */ int IsFastcallFunc (const Type* T) attribute ((const)); -/* Return true if this is a function type or pointer to function type by +/* Return true if this is a function type or pointer to function type with ** __fastcall__ calling convention. ** Check fails if the type is not a function or a pointer to function. */ From 09e0e7412467419a680b98f9b8cbe95fef7adeef Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Thu, 13 May 2021 18:12:12 +0200 Subject: [PATCH 4/6] (again) remove TABs --- libsrc/telestrat/syschdir.s | 2 +- test/val/bug1397.c | 43 ++++++++++++++++++------------------- test/val/bug1451.c | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/libsrc/telestrat/syschdir.s b/libsrc/telestrat/syschdir.s index 149957215..09763bdbb 100644 --- a/libsrc/telestrat/syschdir.s +++ b/libsrc/telestrat/syschdir.s @@ -21,7 +21,7 @@ __syschdir: ; Get name jsr popax - + stx tmp1 ldy tmp1 diff --git a/test/val/bug1397.c b/test/val/bug1397.c index 4f8fb8697..191093efa 100644 --- a/test/val/bug1397.c +++ b/test/val/bug1397.c @@ -7,49 +7,48 @@ unsigned char c; int *p; void f1(void) { - int i = 1; - int *pa = (int *)0xaaaa; - int *pb = (int *)0xbbbb; + int i = 1; + int *pa = (int *)0xaaaa; + int *pb = (int *)0xbbbb; - p = (i == 0) ? pa : pb; - c = 0x5a; + p = (i == 0) ? pa : pb; + c = 0x5a; } struct data_t { - unsigned char c; - int *p; + unsigned char c; + int *p; }; struct data_t data; void f2(void) { - int i = 1; - int *pa = (int *)0xcccc; - int *pb = (int *)0xdddd; - struct data_t *po = &data; - - po->p = (i == 0) ? pa : pb; - po->c = 0xa5; + int i = 1; + int *pa = (int *)0xcccc; + int *pb = (int *)0xdddd; + struct data_t *po = &data; + + po->p = (i == 0) ? pa : pb; + po->c = 0xa5; } int ret = 0; int main(void) { - f1(); + f1(); if (c != 0x5a) { ret++; } - printf("c: %hhx\n", c); - printf("p: %p\n", p); - f2(); + printf("c: %hhx\n", c); + printf("p: %p\n", p); + f2(); if (data.c != 0xa5) { ret++; } - printf("c: %hhx\n", data.c); - printf("p: %p\n", data.p); + printf("c: %hhx\n", data.c); + printf("p: %p\n", data.p); - printf("failures: %d\n", ret); + printf("failures: %d\n", ret); return ret; } - diff --git a/test/val/bug1451.c b/test/val/bug1451.c index c00f19903..f9cca2561 100644 --- a/test/val/bug1451.c +++ b/test/val/bug1451.c @@ -15,7 +15,7 @@ int main(void) S b = {1, 4}; S m[1] = {{6, 3}}; S *p = &a; - + (&a)->a += b.a; p->b += b.b; m->a += b.a; From dfba8d77ca84bb651276aa01f58ca63f61c00f7a Mon Sep 17 00:00:00 2001 From: acqn Date: Sun, 30 Aug 2020 01:31:23 +0800 Subject: [PATCH 5/6] Error messages shouldn't raise warnings about unused expressions by themselves. --- src/cc65/expr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 01bebf18e..a63214f49 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1301,6 +1301,7 @@ static void Primary (ExprDesc* E) /* Statement block */ NextToken (); Error ("Expression expected"); + E->Flags |= E_EVAL_MAYBE_UNUSED; hie0 (E); if (CurTok.Tok == TOK_RCURLY) { NextToken (); @@ -1332,6 +1333,7 @@ static void Primary (ExprDesc* E) } } else { Error ("Expression expected"); + E->Flags |= E_EVAL_MAYBE_UNUSED; NextToken (); } } From 18ae09f6821b3ed15121220100023b70ae393e30 Mon Sep 17 00:00:00 2001 From: acqn Date: Sun, 14 Mar 2021 03:39:05 +0800 Subject: [PATCH 6/6] Less excessive errors with failed array declarations. --- src/cc65/compile.c | 5 ++--- src/cc65/declare.c | 2 +- src/cc65/locals.c | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cc65/compile.c b/src/cc65/compile.c index f970edef7..94dfc3ffb 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -156,9 +156,8 @@ static void Parse (void) ** ** This means that "extern int i;" will not get storage allocated. */ - if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && - (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF && - (Decl.StorageClass & SC_FICTITIOUS) != SC_FICTITIOUS) { + if ((Decl.StorageClass & SC_FUNC) != SC_FUNC && + (Decl.StorageClass & SC_TYPEMASK) != SC_TYPEDEF) { if ((Spec.Flags & DS_DEF_STORAGE) != 0 || (Decl.StorageClass & (SC_EXTERN|SC_STATIC)) == SC_STATIC || ((Decl.StorageClass & SC_EXTERN) != 0 && diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 8879c46d8..a18c837b9 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -2080,7 +2080,7 @@ void ParseDecl (const DeclSpec* Spec, Declaration* D, declmode_t Mode) if (PrevErrorCount != ErrorCount) { /* Make the declaration fictitious if is is not parsed correctly */ - D->StorageClass |= SC_DECL | SC_FICTITIOUS; + D->StorageClass |= SC_FICTITIOUS; if (Mode == DM_NEED_IDENT && D->Ident[0] == '\0') { /* Use a fictitious name for the identifier if it is missing */ diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 7812acebd..c2e314485 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -476,8 +476,7 @@ static void ParseOneDecl (const DeclSpec* Spec) } /* If the symbol is not marked as external, it will be defined now */ - if ((Decl.StorageClass & SC_FICTITIOUS) == 0 && - (Decl.StorageClass & SC_DECL) == 0 && + if ((Decl.StorageClass & SC_DECL) == 0 && (Decl.StorageClass & SC_EXTERN) == 0) { Decl.StorageClass |= SC_DEF; }