* src/SDCCsymt.c (processFuncArgs): fix #498307 by Johan
[fw/sdcc] / src / SDCCsymt.c
index 5592d4a908e08e45ee7a0067ba0fe432c0de4818..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:
@@ -1117,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 */
@@ -1805,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
@@ -1835,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))
@@ -1957,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))
@@ -2355,6 +2352,7 @@ _mangleFunctionName(char *in)
 /*                      'x' - xdata                                */
 /*                      'p' - code                                 */
 /*                      'd' - data                                 */                     
+/*                      'F' - function                             */                     
 /* examples : "ig*" - generic int *                               */
 /*            "cx*" - char xdata *                                 */
 /*            "ui" -  unsigned int                                 */
@@ -2401,6 +2399,7 @@ sym_link *typeFromStr (char *s)
        case 'x':
        case 'p':
        case 'd':
+       case 'F':
            assert(*(s+1)=='*');
            nr = newLink();
            nr->next = r;
@@ -2419,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;