From: Greg King Date: Mon, 10 Aug 2015 17:39:17 +0000 (-0400) Subject: Added warning diagnostics for conflicts between extern/public and static declarations. X-Git-Tag: V2.16~239^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6032849e60dfa51ab1f39f99845d75a07c6e4e10;p=cc65 Added warning diagnostics for conflicts between extern/public and static declarations. --- diff --git a/src/cc65/symtab.c b/src/cc65/symtab.c index 0e4de4ea2..fdf459873 100644 --- a/src/cc65/symtab.c +++ b/src/cc65/symtab.c @@ -813,11 +813,25 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags) } } + /* If a static declaration follows a non-static declaration, then + ** warn about the conflict. (It will compile a public declaration.) + */ + if ((Flags & SC_EXTERN) == 0 && (Entry->Flags & SC_EXTERN) != 0) { + Warning ("static declaration follows non-static declaration of `%s'.", Name); + } + /* An extern declaration must not change the current linkage. */ if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) { Flags &= ~SC_EXTERN; } + /* If a public declaration follows a static declaration, then + ** warn about the conflict. (It will compile a public declaration.) + */ + if ((Flags & SC_EXTERN) != 0 && (Entry->Flags & SC_EXTERN) == 0) { + Warning ("public declaration follows static declaration of `%s'.", Name); + } + /* Add the new flags */ Entry->Flags |= Flags;