fixed the undefined static in reentrant functions
[fw/sdcc] / src / SDCCsymt.c
index aecca442c390de9495d48899af930dd1150297c3..63efeaf3984105b5391ace35ce56013459d65ec6 100644 (file)
@@ -790,7 +790,7 @@ addSymChain (symbol * symHead)
 
   for (; sym != NULL; sym = sym->next)
     {
-
+      changePointer(sym);
       /* if already exists in the symbol table then check if
          the previous was an extern definition if yes then
          then check if the type match, if the types match then
@@ -1055,7 +1055,6 @@ checkSClass (symbol * sym)
        SPEC_SCLS (sym->etype) != S_XSTACK &&
        SPEC_SCLS (sym->etype) != S_CONSTANT))
     {
-
       werror (E_AUTO_ASSUMED, sym->name);
       SPEC_SCLS (sym->etype) = S_AUTO;
     }
@@ -1098,7 +1097,8 @@ checkSClass (symbol * sym)
 
   /* if parameter or local variable then change */
   /* the storage class to reflect where the var will go */
-  if (sym->level && SPEC_SCLS (sym->etype) == S_FIXED)
+  if (sym->level && SPEC_SCLS (sym->etype) == S_FIXED &&
+      !IS_STATIC(sym->etype))
     {
       if (options.stackAuto || (currFunc && IS_RENT (currFunc->etype)))
        {
@@ -1111,7 +1111,7 @@ checkSClass (symbol * sym)
           * control this allcoation, but the code was originally that way, and
           * changing it for non-390 ports breaks the compiler badly.
           */
-         bool useXdata = IS_DS390_PORT ? options.model : options.useXstack;
+         bool useXdata = TARGET_IS_DS390 ? 1 : options.useXstack;
          SPEC_SCLS (sym->etype) = (useXdata ?
                                    S_XDATA : S_FIXED);
        }
@@ -1421,7 +1421,7 @@ aggregateArgToPointer (value * val)
          DCL_TYPE (val->type) = PPOINTER;
          break;
        case S_FIXED:
-         if (IS_DS390_PORT)
+         if (TARGET_IS_DS390)
            {
              /* The AUTO and REGISTER classes should probably
               * also become generic pointers, but I haven't yet
@@ -1594,7 +1594,6 @@ processFuncArgs (symbol * func, int ignoreName)
   value *val;
   int pNum = 1;
 
-
   /* if this function has variable argument list */
   /* then make the function a reentrant one    */
   if (func->hasVargs)
@@ -1621,11 +1620,8 @@ processFuncArgs (symbol * func, int ignoreName)
     {
       /* mark it as a register parameter if
          the function does not have VA_ARG
-         and as port dictates
-         not inhibited by command line option or #pragma */
+         and as port dictates */
       if (!func->hasVargs &&
-         !options.noregparms &&
-         !IS_RENT (func->etype) &&
          (*port->reg_parm) (val->type))
        {
          SPEC_REGPARM (val->etype) = 1;
@@ -1639,10 +1635,19 @@ processFuncArgs (symbol * func, int ignoreName)
       pNum++;
     }
 
-  /* if this function is reentrant or */
-  /* automatics r 2b stacked then nothing */
-  if (IS_RENT (func->etype) || options.stackAuto)
-    return;
+  /* if this is an internal generated function call */
+  if (func->cdef) {
+    /* ignore --stack-auto for this one, we don't know how it is compiled */
+    /* simply trust on --int-long-reent or --float-reent */
+    if (IS_RENT(func->etype)) {
+      return;
+    }
+  } else {
+    /* if this function is reentrant or */
+    /* automatics r 2b stacked then nothing */
+    if (IS_RENT (func->etype) || options.stackAuto)
+      return;
+  }
 
   val = func->args;
   pNum = 1;
@@ -1725,6 +1730,9 @@ printTypeChain (sym_link * type, FILE * of)
     {
       if (IS_DECL (type))
        {
+         if (DCL_PTR_VOLATILE(type)) {
+           fprintf (of, "volatile ");
+         }
          switch (DCL_TYPE (type))
            {
            case FUNCTION:
@@ -1771,7 +1779,6 @@ printTypeChain (sym_link * type, FILE * of)
              if (DCL_PTR_CONST (type))
                fprintf (of, "const ");
              break;
-
            case ARRAY:
              fprintf (of, "array of ");
              break;