* src/SDCCsymt.c: fixed (hopeful properly) bug
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 31 Oct 2007 12:33:37 +0000 (12:33 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 31 Oct 2007 12:33:37 +0000 (12:33 +0000)
  #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

ChangeLog
src/SDCCsymt.c
support/regression/tests/bug-1805702.c

index 75adf0e3889640dfb3dd2fffa04b27aafc031794..bb4a4847bd9395a63945b80bf5b1d40b4fb78b40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-10-31 Borut Razem <borut.razem AT siol.net>
+
+       * 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 <borut.razem AT siol.net>
 
        * src/SDCCsymt.c: reverted bad fixed of bug #1805702
index 1e02f3cdf913f7409b77673229d4ceaadd09b495..1995e05caab2d89407a117db0d54d9456395bc0c 100644 (file)
@@ -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);
index aaeac00ee50a58bd28ed84b8edbb811c085d934c..eb6ca043589de4787dbb03d16d5cb5b21ab2fd68 100644 (file)
@@ -3,19 +3,30 @@
 
 #include <testfwk.h>
 
-/* 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);
 }