Changed default documentation dir to share/doc/sdcc
[fw/sdcc] / src / SDCCsymt.c
index ee4bfe42f54ee2ec0361913bcd50bb954871b694..9db4cf03c2c64186e415998c4e6bb5a9c0cce988 100644 (file)
@@ -499,7 +499,7 @@ void checkTypeSanity(sym_link *etype, char *name) {
 
   // special case for "short"
   if (etype->select.s._short) {
-    SPEC_NOUN(etype) = options.shortisint ? V_INT : V_CHAR;
+    SPEC_NOUN(etype) = options.shortis8bits ? V_CHAR : V_INT;
     etype->select.s._short = 0;
   }
 
@@ -935,7 +935,7 @@ addSymChain (symbol * symHead)
          if (IS_EXTERN (csym->etype))
            {
              /* do types match ? */
-             if (checkType (csym->type, sym->type) != 1)
+             if (compareType (csym->type, sym->type) != 1)
                /* no then error */
                werror (E_DUPLICATE, csym->name);
 
@@ -956,7 +956,7 @@ addSymChain (symbol * symHead)
          /* then check the type with the current one         */
          if (IS_EXTERN (csym->etype))
            {
-             if (checkType (csym->type, sym->type) <= 0)
+             if (compareType (csym->type, sym->type) <= 0)
                werror (W_EXTERN_MISMATCH, csym->name);
            }
        }
@@ -1178,6 +1178,7 @@ checkSClass (symbol * sym)
       sym->ival = NULL;
     }
 
+#if 0
   /* if this is an automatic symbol then */
   /* storage class will be ignored and   */
   /* symbol will be allocated on stack/  */
@@ -1193,6 +1194,23 @@ checkSClass (symbol * sym)
       werror (E_AUTO_ASSUMED, sym->name);
       SPEC_SCLS (sym->etype) = S_AUTO;
     }
+#else
+  /* if this is an atomatic symbol */
+  if (sym->level && (options.stackAuto || reentrant)) {
+    if ((SPEC_SCLS (sym->etype) == S_AUTO ||
+        SPEC_SCLS (sym->etype) == S_FIXED ||
+        SPEC_SCLS (sym->etype) == S_REGISTER ||
+        SPEC_SCLS (sym->etype) == S_STACK ||
+        SPEC_SCLS (sym->etype) == S_XSTACK)) {
+      SPEC_SCLS (sym->etype) = S_AUTO;
+    } else {
+      /* storage class may only be specified for statics */
+      if (!IS_STATIC(sym->etype)) {
+       werror (E_AUTO_ASSUMED, sym->name);
+      }
+    }
+  }
+#endif
   
   /* automatic symbols cannot be given   */
   /* an absolute address ignore it      */
@@ -1410,10 +1428,10 @@ computeType (sym_link * type1, sym_link * type2)
 }
 
 /*------------------------------------------------------------------*/
-/* checkType - will do type check return 1 if match                 */
+/* compareType - will do type check return 1 if match                 */
 /*------------------------------------------------------------------*/
 int 
-checkType (sym_link * dest, sym_link * src)
+compareType (sym_link * dest, sym_link * src)
 {
   if (!dest && !src)
     return 1;
@@ -1430,13 +1448,13 @@ checkType (sym_link * dest, sym_link * src)
       if (IS_DECL (src))
        {
          if (DCL_TYPE (src) == DCL_TYPE (dest))
-           return checkType (dest->next, src->next);
+           return compareType (dest->next, src->next);
          else if (IS_PTR (src) && IS_PTR (dest))
            return -1;
          else if (IS_PTR (dest) && IS_ARRAY (src))
            return -1;
          else if (IS_PTR (dest) && IS_FUNC (dest->next) && IS_FUNC (src))
-           return -1 * checkType (dest->next, src);
+           return -1 * compareType (dest->next, src);
          else
            return 0;
        }
@@ -1642,7 +1660,7 @@ checkFunction (symbol * sym)
     }
 
   /* check the return value type   */
-  if (checkType (csym->type, sym->type) <= 0)
+  if (compareType (csym->type, sym->type) <= 0)
     {
       werror (E_PREV_DEF_CONFLICT, csym->name, "type");
       werror (E_CONTINUE, "previous definition type ");
@@ -1698,7 +1716,7 @@ checkFunction (symbol * sym)
          checkValue = acargs;
        }
 
-      if (checkType (exargs->type, checkValue->type) <= 0)
+      if (compareType (exargs->type, checkValue->type) <= 0)
        {
          werror (E_ARG_TYPE, argCnt);
          return 0;
@@ -2236,6 +2254,19 @@ _makeRegParam (symbol * sym)
     }
 }
 
+static char *
+_mangleFunctionName(char *in)
+{
+  if (port->getMangledFunctionName) 
+    {
+      return port->getMangledFunctionName(in);
+    }
+  else
+    {
+      return in;
+    }
+}
+
 /*-----------------------------------------------------------------*/
 /* initCSupport - create functions for C support routines          */
 /*-----------------------------------------------------------------*/
@@ -2301,12 +2332,12 @@ initCSupport ()
              if (tofrom)
                {
                  sprintf (buffer, "__fs2%s%s", ssu[su], sbwd[bwd]);
-                 __conv[tofrom][bwd][su] = funcOfType (buffer, __multypes[bwd][su], floatType, 1, options.float_rent);
+                 __conv[tofrom][bwd][su] = funcOfType (_mangleFunctionName(buffer), __multypes[bwd][su], floatType, 1, options.float_rent);
                }
              else
                {
                  sprintf (buffer, "__%s%s2fs", ssu[su], sbwd[bwd]);
-                 __conv[tofrom][bwd][su] = funcOfType (buffer, floatType, __multypes[bwd][su], 1, options.float_rent);
+                 __conv[tofrom][bwd][su] = funcOfType (_mangleFunctionName(buffer), floatType, __multypes[bwd][su], 1, options.float_rent);
                }
            }
        }
@@ -2322,7 +2353,7 @@ initCSupport ()
                       smuldivmod[muldivmod],
                       ssu[su],
                       sbwd[bwd]);
-              __muldiv[muldivmod][bwd][su] = funcOfType (buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
+              __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]);