fixed bug #498740
[fw/sdcc] / src / SDCCsymt.c
index ac088cc992d1c160267a3b8b5015f0f5a847a995..41df8a654d1d3c98d5bf18d3adbfe7f4a19b1522 100644 (file)
@@ -790,8 +790,8 @@ getSize (sym_link * p)
       if (DCL_ELEM(p)) {
        return DCL_ELEM (p) * getSize (p->next);
       } else {
-       werror (E_INTERNAL_ERROR, __FILE__, __LINE__, 
-               "can not tell the size of an array[]");
+         //    werror (E_INTERNAL_ERROR, __FILE__, __LINE__, 
+         //    "can not tell the size of an array[]");
        return 0;
       }
     case IPOINTER:
@@ -990,6 +990,7 @@ addSymChain (symbol * symHead)
          }
          /* delete current entry */
          deleteSym (SymbolTab, csym, csym->name);
+         deleteFromSeg(csym);
        } else {
          /* not extern */
          werror (E_DUPLICATE, sym->name);
@@ -1116,13 +1117,6 @@ compStructSize (int su, structdef * sdef)
            sum += getSize (loop->type);
        }
 
-#if 0 // jwk: this is done now in addDecl()
-       /* if function then do the arguments for it */
-       if (funcInChain (loop->type)) {
-           processFuncArgs (loop);
-       }
-#endif
-
        loop = loop->next;
 
        /* if this is not a bitfield but the */
@@ -1180,8 +1174,10 @@ checkSClass (symbol * sym, int isProto)
     SPEC_VOLATILE (sym->etype) = 1;
   
   /* global variables declared const put into code */
+  /* if no other storage class specified */
   if (sym->level == 0 &&
-      SPEC_CONST (sym->etype)) {
+      SPEC_CONST (sym->etype) &&
+      SPEC_SCLS(sym->etype) == S_FIXED) {
     SPEC_SCLS (sym->etype) = S_CODE;
   }
   
@@ -1772,6 +1768,7 @@ checkFunction (symbol * sym, symbol *csym)
   /* replace with this defition */
   sym->cdef = csym->cdef;
   deleteSym (SymbolTab, csym, csym->name);
+  deleteFromSeg(csym);
   addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
   if (IS_EXTERN (csym->etype) && !
       IS_EXTERN (sym->etype))
@@ -1801,7 +1798,7 @@ processFuncArgs (symbol * func)
 
   /* if this function has variable argument list */
   /* then make the function a reentrant one    */
-  if (IFFUNC_HASVARARGS(funcType))
+  if (IFFUNC_HASVARARGS(funcType) || (options.stackAuto && !func->cdef))
     FUNC_ISREENT(funcType)=1;
 
   /* check if this function is defined as calleeSaves
@@ -1831,6 +1828,8 @@ processFuncArgs (symbol * func)
          (*port->reg_parm) (val->type))
        {
          SPEC_REGPARM (val->etype) = 1;
+       } else if (IFFUNC_ISREENT(funcType)) {
+           FUNC_HASSTACKPARM(funcType) = 1;
        }
 
       if (IS_AGGREGATE (val->type))
@@ -1953,7 +1952,9 @@ printTypeChain (sym_link * start, FILE * of)
          switch (DCL_TYPE (type))
            {
            case FUNCTION:
-             fprintf (of, "function %s", (IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "));
+             fprintf (of, "function %s %s", 
+                      (IFFUNC_ISBUILTIN(type) ? "__builtin__" : " "),
+                      (IFFUNC_ISJAVANATIVE(type) ? "_JavaNative" : " "));
              break;
            case GPOINTER:
              if (DCL_PTR_CONST (type))
@@ -2351,6 +2352,7 @@ _mangleFunctionName(char *in)
 /*                      'x' - xdata                                */
 /*                      'p' - code                                 */
 /*                      'd' - data                                 */                     
+/*                      'F' - function                             */                     
 /* examples : "ig*" - generic int *                               */
 /*            "cx*" - char xdata *                                 */
 /*            "ui" -  unsigned int                                 */
@@ -2397,6 +2399,7 @@ sym_link *typeFromStr (char *s)
        case 'x':
        case 'p':
        case 'd':
+       case 'F':
            assert(*(s+1)=='*');
            nr = newLink();
            nr->next = r;
@@ -2415,6 +2418,14 @@ sym_link *typeFromStr (char *s)
            case 'd':
                DCL_TYPE(r) = POINTER;
                break;
+           case 'F':
+               DCL_TYPE(r) = FUNCTION;
+               nr = newLink();
+               nr->next = r;
+               r = nr;
+               r->class = DECLARATOR ;
+               DCL_TYPE(r) = CPOINTER;
+               break;
            }
            s++;
            break;