Added simple assertions to help bug tracking
[fw/sdcc] / src / SDCCsymt.c
index f830136954bce1767e639ed8b77cac9d9f8f9db2..a6052bf9831d0d29b6b059104b75b4afa01d8a64 100644 (file)
@@ -943,6 +943,7 @@ addSymChain (symbol * symHead)
 {
   symbol *sym = symHead;
   symbol *csym = NULL;
+  int bothSymbolsExtern;
 
 
   for (; sym != NULL; sym = sym->next)
@@ -950,16 +951,18 @@ addSymChain (symbol * symHead)
       changePointer(sym);
 
       /* if already exists in the symbol table then check if
-         the previous was an extern definition if yes then
+         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)
        {
 
-         /* previous definition extern ? */
-         if (IS_EXTERN (csym->etype))
+         /* 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 */
@@ -967,6 +970,10 @@ addSymChain (symbol * symHead)
 
              /* 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);
            }
@@ -2261,25 +2268,11 @@ symbol *__muldiv[3][3][2];
 sym_link *__multypes[3][2];
 /* Dims: to/from float, BYTE/WORD/DWORD, SIGNED/USIGNED */
 symbol *__conv[2][3][2];
+/* Dims: shift left/shift right, BYTE/WORD/DWORD, SIGNED/UNSIGNED */
+symbol *__rlrr[2][3][2];
 
 sym_link *floatType;
 
-static void 
-_makeRegParam (symbol * sym)
-{
-  value *val;
-
-  val = sym->args;             /* loop thru all the arguments   */
-
-  /* reset regparm for the port */
-  (*port->reset_regparms) ();
-  while (val)
-    {
-      SPEC_REGPARM (val->etype) = 1;
-      val = val->next;
-    }
-}
-
 static char *
 _mangleFunctionName(char *in)
 {
@@ -2311,8 +2304,12 @@ initCSupport ()
   {
     "s", "u"
   };
+  const char *srlrr[] =
+  {
+    "rl", "rr"
+  };
 
-  int bwd, su, muldivmod, tofrom;
+  int bwd, su, muldivmod, tofrom, rlrr;
 
   floatType = newFloatLink ();
 
@@ -2381,8 +2378,22 @@ initCSupport ()
                       sbwd[bwd]);
               __muldiv[muldivmod][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
              SPEC_NONBANKED (__muldiv[muldivmod][bwd][su]->etype) = 1;
-             if (bwd < port->muldiv.force_reg_param_below)
-               _makeRegParam (__muldiv[muldivmod][bwd][su]);
+           }
+       }
+    }
+
+  for (rlrr = 0; rlrr < 2; rlrr++)
+    {
+      for (bwd = 0; bwd < 3; bwd++)
+       {
+         for (su = 0; su < 2; su++)
+           {
+             sprintf (buffer, "_%s%s%s",
+                      srlrr[rlrr],
+                      ssu[su],
+                      sbwd[bwd]);
+              __rlrr[rlrr][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], __multypes[0][0], 2, options.intlong_rent);
+             SPEC_NONBANKED (__rlrr[rlrr][bwd][su]->etype) = 1;
            }
        }
     }