fixed bug 449137/453886
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 22 Aug 2001 11:07:44 +0000 (11:07 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 22 Aug 2001 11:07:44 +0000 (11:07 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1162 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCsymt.c
support/Util/SDCCerr.c
support/Util/SDCCerr.h

index a6052bf9831d0d29b6b059104b75b4afa01d8a64..4717bf10b60664e0e99ea3d0424ed723a9ac5f44 100644 (file)
@@ -943,56 +943,37 @@ addSymChain (symbol * symHead)
 {
   symbol *sym = symHead;
   symbol *csym = NULL;
-  int bothSymbolsExtern;
-
 
   for (; sym != NULL; sym = sym->next)
     {
       changePointer(sym);
+      checkTypeSanity(sym->etype, sym->name);
 
       /* if already exists in the symbol table then check if
          one of them is an extern definition if yes then
          then check if the type match, if the types match then
          delete the current entry and add the new entry      */
       if ((csym = findSymWithLevel (SymbolTab, sym)) &&
-         csym->level == sym->level)
-       {
-
-         /* one definition extern ? */
-         if (IS_EXTERN (csym->etype) || IS_EXTERN (sym->etype))
-           {
-             bothSymbolsExtern=
-               IS_EXTERN (csym->etype) && IS_EXTERN (sym->etype);
-             /* do types match ? */
-             if (compareType (csym->type, sym->type) != 1)
-               /* no then error */
-               werror (E_DUPLICATE, csym->name);
-
-             /* delete current entry */
-             deleteSym (SymbolTab, csym, csym->name);
-
-             /* this isn't really needed, but alla */
-             sym->etype->select.s._extern=bothSymbolsExtern;
-
-             /* add new entry */
-             addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
-           }
-         else                  /* not extern */
-           werror (E_DUPLICATE, sym->name);
+         csym->level == sym->level) {
+       
+       /* one definition extern ? */
+       if (IS_EXTERN (csym->etype) || IS_EXTERN (sym->etype)) {
+         /* do types match ? */
+         if (compareType (csym->type, sym->type) != 1) {
+           /* no then error */
+           werror (E_EXTERN_MISMATCH, csym->name);
+           continue;
+         }
+         /* delete current entry */
+         deleteSym (SymbolTab, csym, csym->name);
+       } else {
+         /* not extern */
+         werror (E_DUPLICATE, sym->name);
          continue;
        }
+      }
 
-      /* check if previously defined */
-      if (csym && csym->level == sym->level)
-       {
-         /* if the previous one was declared as extern */
-         /* then check the type with the current one         */
-         if (IS_EXTERN (csym->etype))
-           {
-             if (compareType (csym->type, sym->type) <= 0)
-               werror (W_EXTERN_MISMATCH, csym->name);
-           }
-       }
+      /* add new entry */
       addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
     }
 }
index 795eb9fe27dffdec9c2b8f5ca7ce225f76748ee1..92e86883ff40d85db904bed94b3421f772a184fc 100644 (file)
@@ -233,7 +233,7 @@ struct
    "%s '%s' address out of range" },
 { E_BITVAR_STORAGE, ERROR_LEVEL_ERROR,
    "storage class CANNOT be specified for bit variable '%s'" },
-{ W_EXTERN_MISMATCH, ERROR_LEVEL_WARNING,
+{ E_EXTERN_MISMATCH, ERROR_LEVEL_ERROR,
    "extern definition for '%s' mismatches with declaration." },
 { E_NONRENT_ARGS, ERROR_LEVEL_WARNING,
    "Functions called via pointers must be 'reentrant' to take arguments" },
index 045fe6f3c7a77eabf2ab5bfa75a2243761f8b290..24d28264fc247b9a795a62cba0e74a452c904e92 100644 (file)
@@ -106,7 +106,7 @@ SDCCERR - SDCC Standard error handler
 #define  W_LITERAL_GENERIC  88         /* literal being cast to generic pointer */
 #define  E_SFR_ADDR_RANGE   89         /* sfr address out of range                     */
 #define         E_BITVAR_STORAGE   90          /* storage given for 'bit' variable     */
-#define  W_EXTERN_MISMATCH  91         /* extern declaration mismatches    */
+#define  E_EXTERN_MISMATCH  91         /* extern declaration mismatches    */
 #define  E_NONRENT_ARGS            92          /* fptr non reentrant has args          */
 #define  W_DOUBLE_UNSUPPORTED 93       /* 'double' not supported yet                   */
 #define  W_IF_NEVER_TRUE    94         /* if always false                                      */