1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Fix the warning that is produced for unused functions

This commit is contained in:
mrdudz 2021-05-07 18:38:26 +02:00 committed by Oliver Schmidt
parent 216bb22b20
commit 0fbf2af09d
3 changed files with 7 additions and 0 deletions

View File

@ -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" },

View File

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

View File

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