]> git.sur5r.net Git - cc65/blobdiff - src/cc65/symtab.c
Fixed two compiler warnings.
[cc65] / src / cc65 / symtab.c
index 4e4ebbc82cb778c767b658d60db232eac0faf2f5..db6541ee7fda8f9e1461232b7208c454d1d4014d 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2009, Ullrich von Bassewitz                                      */
+/* (C) 2000-2011, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -41,7 +41,7 @@
 /* common */
 #include "check.h"
 #include "debugflag.h"
-#include "hashstr.h"
+#include "hashfunc.h"
 #include "xmalloc.h"
 
 /* cc65 */
@@ -162,11 +162,16 @@ static void CheckSymTable (SymTable* Tab)
             * defined but not used.
             */
            if (((Flags & SC_AUTO) || (Flags & SC_STATIC)) && (Flags & SC_EXTERN) == 0) {
-               if (SymIsDef (Entry) && !SymIsRef (Entry)) {
+               if (SymIsDef (Entry) && !SymIsRef (Entry) &&
+                    !SymHasAttr (Entry, atUnused)) {
                    if (Flags & SC_PARAM) {
-                       Warning ("Parameter `%s' is never used", Entry->Name);
+                        if (IS_Get (&WarnUnusedParam)) {
+                           Warning ("Parameter `%s' is never used", Entry->Name);
+                        }
                    } else {
-                       Warning ("`%s' is defined but never used", Entry->Name);
+                        if (IS_Get (&WarnUnusedVar)) {
+                            Warning ("`%s' is defined but never used", Entry->Name);
+                        }
                    }
                }
            }
@@ -178,7 +183,9 @@ static void CheckSymTable (SymTable* Tab)
                    Error ("Undefined label: `%s'", Entry->Name);
                } else if (!SymIsRef (Entry)) {
                    /* Defined but not used */
-                   Warning ("`%s' is defined but never used", Entry->Name);
+                    if (IS_Get (&WarnUnusedLabel)) {
+                       Warning ("`%s' is defined but never used", Entry->Name);
+                    }
                }
            }
 
@@ -762,7 +769,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
                TypeCmp (T + 1, EType + 1) < TC_EQUAL) {
                /* Types not identical: Conflicting types */
                Error ("Conflicting types for `%s'", Name);
-               return Entry;
+               return Entry;
            } else {
                /* Check if we have a size in the existing definition */
                if (ESize == UNSPECIFIED) {
@@ -775,7 +782,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
            /* New type must be identical */
            if (TypeCmp (EType, T) < TC_EQUAL) {
                Error ("Conflicting types for `%s'", Name);
-               return Entry;
+               return Entry;
            }
 
            /* In case of a function, use the new type descriptor, since it
@@ -785,9 +792,9 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
              * empty parameter list.
             */
            if (IsFunc) {
-               /* Get the function descriptor from the new type */
-               FuncDesc* F = GetFuncDesc (T);
-               /* Use this new function descriptor if it doesn't contain
+               /* Get the function descriptor from the new type */
+               FuncDesc* F = GetFuncDesc (T);
+               /* Use this new function descriptor if it doesn't contain
                  * an empty parameter list.
                  */
                 if ((F->Flags & FD_EMPTY) == 0) {
@@ -939,3 +946,43 @@ void EmitExternals (void)
 
 
 
+void EmitDebugInfo (void)
+/* Emit debug infos for the locals of the current scope */
+{
+    const char* Head;
+    const SymEntry* Sym;
+
+    /* Output info for locals if enabled */
+    if (DebugInfo) {
+        /* For cosmetic reasons in the output file, we will insert two tabs
+         * on global level and just one on local level.
+         */
+        if (LexicalLevel == LEX_LEVEL_GLOBAL) {
+            Head = "\t.dbg\t\tsym";
+        } else {
+            Head = "\t.dbg\tsym";
+        }
+        Sym = SymTab->SymHead;
+        while (Sym) {
+            if ((Sym->Flags & (SC_CONST|SC_TYPE)) == 0) {
+                if (Sym->Flags & SC_AUTO) {
+                    AddTextLine ("%s, \"%s\", \"00\", auto, %d",
+                                 Head, Sym->Name, Sym->V.Offs);
+                } else if (Sym->Flags & SC_REGISTER) {
+                    AddTextLine ("%s, \"%s\", \"00\", register, \"regbank\", %d",
+                                 Head, Sym->Name, Sym->V.R.RegOffs);
+
+                } else if (SymIsRef (Sym) && !SymIsDef (Sym)) {
+                    AddTextLine ("%s, \"%s\", \"00\", %s, \"%s\"",
+                                 Head, Sym->Name,
+                                 (Sym->Flags & SC_EXTERN)? "extern" : "static",
+                                 Sym->AsmName);
+                }
+            }
+            Sym = Sym->NextSym;
+        }
+    }
+}
+
+
+