Merge pull request #2309 from acqn/Diagnostics

[cc65] Added warning on static functions that are used but not defined
This commit is contained in:
Bob Andrews 2023-12-31 19:15:48 +01:00 committed by GitHub
commit 9e3d1e1027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -281,11 +281,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.
@ -547,10 +548,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);
}
}
}