From 6032849e60dfa51ab1f39f99845d75a07c6e4e10 Mon Sep 17 00:00:00 2001 From: Greg King Date: Mon, 10 Aug 2015 13:39:17 -0400 Subject: [PATCH] Added warning diagnostics for conflicts between extern/public and static declarations. --- src/cc65/symtab.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; -- 2.39.5