diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 7912b85a9..56a87ae72 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -563,6 +563,8 @@ Here is a description of all the command line options: Warn about #pragmas that aren't recognized by cc65. Warn about unreachable code in cases of comparing constants, etc. + + Warn about unused functions. Warn about unused labels. diff --git a/include/time.h b/include/time.h index 49d7e6870..92cbeee37 100644 --- a/include/time.h +++ b/include/time.h @@ -98,11 +98,11 @@ extern struct _timezone { # define CLOCKS_PER_SEC 50 #elif defined(__PCE__) # define CLOCKS_PER_SEC 60 -#elif defined(__GAMATE__) +#elif defined(__GAMATE__) # define CLOCKS_PER_SEC 135 /* FIXME */ -#elif defined(__GEOS__) +#elif defined(__GEOS__) # define CLOCKS_PER_SEC 1 -#else +#elif defined(__ATARI__) || defined (__LYNX__) /* Read the clock rate at runtime */ clock_t _clocks_per_sec (void); # define CLOCKS_PER_SEC _clocks_per_sec() diff --git a/libsrc/atari5200/y2k.inc b/libsrc/atari5200/y2k.inc index a44d027a1..f8531451c 100644 --- a/libsrc/atari5200/y2k.inc +++ b/libsrc/atari5200/y2k.inc @@ -32,10 +32,8 @@ Y2K3 STA $0732,X LDA #$60 ; Store RTS opcode @ end STA $0750 JSR $0600 ; Show title screen - LDY #$00 ; Clear RAM from $0600-$3FFF + LDY #<$0600 ; Clear RAM from $0600-$3FFF STY $80 - LDA #$06 + LDA #>$0600 STA $81 - JSR CLRRAM - RTS - + JMP CLRRAM diff --git a/libsrc/common/strlen.s b/libsrc/common/strlen.s index e89039179..8d5bc20fc 100644 --- a/libsrc/common/strlen.s +++ b/libsrc/common/strlen.s @@ -5,17 +5,27 @@ ; the usage of only ptr2 here! Keep in mind when appling changes ; and check the other implementations too! ; -; int strlen (const char* s); +; size_t __fastcall__ strlen (const char* s); ; .export _strlen .importzp ptr2 + .macpack cpu _strlen: sta ptr2 ; Save s stx ptr2+1 +.if (.cpu .bitand ::CPU_ISET_HUC6280) + clx + cly +.else ldx #0 ; YX used as counter +.if (.cpu .bitand ::CPU_ISET_65816) + txy +.else ldy #0 +.endif +.endif L1: lda (ptr2),y beq L9 diff --git a/src/cc65/error.c b/src/cc65/error.c index 0118d50b8..b1529d0b5 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -78,6 +78,7 @@ IntStack WarnUnreachableCode= INTSTACK(1); /* - unreachable code */ IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */ IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */ IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */ +IntStack WarnUnusedFunc = INTSTACK(1); /* - unused functions */ /* Map the name of a warning to the intstack that holds its state */ typedef struct WarnMapEntry WarnMapEntry; @@ -97,6 +98,7 @@ static WarnMapEntry WarnMap[] = { { &WarnStructParam, "struct-param" }, { &WarnUnknownPragma, "unknown-pragma" }, { &WarnUnreachableCode, "unreachable-code" }, + { &WarnUnusedFunc, "unused-func" }, { &WarnUnusedLabel, "unused-label" }, { &WarnUnusedParam, "unused-param" }, { &WarnUnusedVar, "unused-var" }, diff --git a/src/cc65/error.h b/src/cc65/error.h index 31c46f513..c4420c434 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -75,6 +75,7 @@ extern IntStack WarnUnreachableCode; /* - unreachable code */ extern IntStack WarnUnusedLabel; /* - unused labels */ extern IntStack WarnUnusedParam; /* - unused parameters */ extern IntStack WarnUnusedVar; /* - unused variables */ +extern IntStack WarnUnusedFunc; /* - unused functions */ /* Forward */ struct StrBuf; diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 6ec255497..4073a38bc 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -173,6 +173,10 @@ static void CheckSymTable (SymTable* Tab) if (IS_Get (&WarnUnusedParam)) { Warning ("Parameter '%s' is never used", Entry->Name); } + } else if (Flags & SC_FUNC) { + if (IS_Get (&WarnUnusedFunc)) { + Warning ("Function '%s' is defined but never used", Entry->Name); + } } else { if (IS_Get (&WarnUnusedVar)) { Warning ("Variable '%s' is defined but never used", Entry->Name);