]> git.sur5r.net Git - cc65/blobdiff - src/cc65/symtab.c
Fixed a bug
[cc65] / src / cc65 / symtab.c
index 988190cd6a50a462790cde0a3c29433774e63bcb..2c50775d797ffe9e96eaa1993fcc71d5f0141596 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2001 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 2000-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
@@ -40,6 +40,7 @@
 
 /* common */
 #include "check.h"
+#include "debugflag.h"
 #include "hashstr.h"
 #include "xmalloc.h"
 
@@ -81,9 +82,6 @@ SymTable      EmptySymTab = {
 #define SYMTAB_SIZE_STRUCT      19U
 #define SYMTAB_SIZE_LABEL        7U
 
-/* Predefined lexical levels */
-#define LEX_LEVEL_GLOBAL       1U
-
 /* The current and root symbol tables */
 static unsigned                LexicalLevel    = 0;    /* For safety checks */
 static SymTable*       SymTab0         = 0;
@@ -198,6 +196,14 @@ static void CheckSymTable (SymTable* Tab)
 
 
 
+unsigned GetLexicalLevel (void)
+/* Return the current lexical level */
+{
+    return LexicalLevel;
+}
+
+
+
 void EnterGlobalLevel (void)
 /* Enter the program global lexical level */
 {
@@ -711,17 +717,17 @@ SymEntry* AddGlobalSym (const char* Name, const type* Type, unsigned Flags)
        if (IsTypeArray (Type) && IsTypeArray (EType)) {
 
            /* Get the array sizes */
-           unsigned Size  = Decode (Type + 1);
-           unsigned ESize = Decode (EType + 1);
+           long Size  = GetElementCount (Type);
+           long ESize = GetElementCount (EType);
 
-           if ((Size != 0 && ESize != 0 && Size != ESize) ||
+                   if ((Size != UNSPECIFIED && ESize != UNSPECIFIED && Size != ESize) ||
                TypeCmp (Type+DECODE_SIZE+1, EType+DECODE_SIZE+1) < TC_EQUAL) {
                /* Types not identical: Conflicting types */
                Error ("Conflicting types for `%s'", Name);
                return Entry;
            } else {
                /* Check if we have a size in the existing definition */
-               if (ESize == 0) {
+               if (ESize == UNSPECIFIED) {                           
                    /* Existing, size not given, use size from new def */
                    Encode (EType + 1, Size);
                }