1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Added warning on static functions that are used but not defined.

This commit is contained in:
acqn 2023-12-14 21:27:48 +08:00
parent 05aae60816
commit a5746227dc

View File

@ -273,11 +273,12 @@ static void Parse (void)
if (IsTypeVoid (Decl.Type)) {
/* We cannot declare variables of type void */
Error ("Illegal type for variable '%s'", Decl.Ident);
Sym->Flags &= ~(SC_STORAGE | SC_DEF);
Sym->Flags |= SC_DEF;
} else if (Size == 0 && SymIsDef (Sym) && !IsEmptiableObjectType (Decl.Type)) {
/* Size is unknown. Is it an array? */
if (!IsTypeArray (Decl.Type)) {
Error ("Variable '%s' has unknown size", Decl.Ident);
Sym->Flags |= SC_DEF;
}
} else {
/* Check for enum forward declaration.
@ -539,10 +540,16 @@ void Compile (const char* FileName)
Entry->Flags |= SC_DEF;
} else if (!IsTypeArray (Entry->Type)) {
/* Tentative declared variable is still of incomplete type */
Error ("Definition of '%s' has type '%s' that is never completed",
Error ("Definition of '%s' never has its type '%s' completed",
Entry->Name,
GetFullTypeName (Entry->Type));
}
} else if (!SymIsDef (Entry) && (Entry->Flags & SC_FUNC) == SC_FUNC) {
/* Check for undefined functions */
if ((Entry->Flags & (SC_EXTERN | SC_STATIC)) == SC_STATIC && SymIsRef (Entry)) {
Warning ("Static function '%s' used but never defined",
Entry->Name);
}
}
}