From 052fdbee7c41dd77380e3a6d323a3f4d5c12eebf Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 22 Aug 2001 11:07:44 +0000 Subject: [PATCH] fixed bug 449137/453886 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1162 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCsymt.c | 55 ++++++++++++++---------------------------- support/Util/SDCCerr.c | 2 +- support/Util/SDCCerr.h | 2 +- 3 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index a6052bf9..4717bf10 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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); } } diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 795eb9fe..92e86883 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -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" }, diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index 045fe6f3..24d28264 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -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 */ -- 2.30.2