From: borutr Date: Wed, 31 Oct 2007 12:33:37 +0000 (+0000) Subject: * src/SDCCsymt.c: fixed (hopeful properly) bug X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=72a11236b6d17bf2ddbbce2ff0dd2d857523f2a7;p=fw%2Fsdcc * src/SDCCsymt.c: fixed (hopeful properly) bug #1805702 - order of extern matters * support/regression/tests/bug-1805702.c: enabled regtest for bug #1805702 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4956 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 75adf0e3..bb4a4847 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-31 Borut Razem + + * src/SDCCsymt.c: fixed (hopeful properly) bug + #1805702 - order of extern matters + * support/regression/tests/bug-1805702.c: enabled regtest for bug + #1805702 + 2007-10-29 Borut Razem * src/SDCCsymt.c: reverted bad fixed of bug #1805702 diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 1e02f3cd..1995e05c 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1082,11 +1082,7 @@ addSymChain (symbol ** symHead) DCL_ELEM (sym->type) = getNelements (sym->type, sym->ival); } - /* 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 already exists in the symbol table on the same level */ if ((csym = findSymWithLevel (SymbolTab, sym)) && csym->level == sym->level) { @@ -1097,9 +1093,9 @@ addSymChain (symbol ** symHead) error = 1; else { - /* If the previous definition was for an array with incomplete */ - /* type, and the new definition has completed the type, update */ - /* the original type to match */ + /* If the previous definition was for an array with incomplete + type, and the new definition has completed the type, update + the original type to match */ if (IS_DECL(csym->type) && DCL_TYPE(csym->type)==ARRAY && IS_DECL(sym->type) && DCL_TYPE(sym->type)==ARRAY) { @@ -1156,6 +1152,14 @@ addSymChain (symbol ** symHead) if (csym->ival && !sym->ival) sym->ival = csym->ival; + if (!csym->cdef && !sym->cdef && IS_EXTERN (sym->etype)) + { + /* if none of symbols is a compiler defined function + and at least one is not extern + then set the new symbol to non extern */ + SPEC_EXTR(sym->etype) = SPEC_EXTR(csym->etype); + } + /* delete current entry */ deleteSym (SymbolTab, csym, csym->name); deleteFromSeg(csym); diff --git a/support/regression/tests/bug-1805702.c b/support/regression/tests/bug-1805702.c index aaeac00e..eb6ca043 100644 --- a/support/regression/tests/bug-1805702.c +++ b/support/regression/tests/bug-1805702.c @@ -3,19 +3,30 @@ #include -/* disabled */ -#if 0 int foo; extern int foo; -#endif void test(void) { -/* disabled */ -#if 0 foo = 10; ASSERT(foo == 10); -#endif +} + +/* compile time check for compiler defined functions (cdef) */ + +float __fsmul (float, float); + +/* multiply two floats */ +float __fsmul (float a1, float a2) { + return (a1 + a2); +} + +extern unsigned char _divuchar (unsigned char a, unsigned char b); + +signed char +_divschar (signed char a, signed char b) +{ + return _divuchar ((unsigned int)a, (unsigned int)b); }