more function pointer parameter issues
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Nov 2001 16:31:05 +0000 (16:31 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Nov 2001 16:31:05 +0000 (16:31 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1496 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCast.h
src/SDCCicode.c
src/SDCCmem.c
src/SDCCsymt.c
src/SDCCsymt.h

index a87ac07af4d928c7ad8447903cc65d5bb3667c85..189216815a0652776a06e48bf869ceb537abd859 100644 (file)
@@ -3094,7 +3094,6 @@ decorateType (ast * tree)
       if (processParms (tree->left,
                        FUNC_ARGS(tree->left->ftype),
                        tree->right, &parmNumber, TRUE)) {
-       //fprintf (stderr, "jwk: error in processParms()\n");
        goto errorTreeReturn;
       }
 
@@ -4102,6 +4101,9 @@ createFunction (symbol * name, ast * body)
   sym_link *fetype;
   iCode *piCode = NULL;
 
+  if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+    fprintf (stderr, "SDCCast.c:createFunction(%s)\n", name->name);
+
   /* if check function return 0 then some problem */
   if (checkFunction (name, NULL) == 0)
     return NULL;
@@ -4132,7 +4134,10 @@ createFunction (symbol * name, ast * body)
     }
   name->lastLine = yylineno;
   currFunc = name;
-  processFuncArgs (currFunc, 0);
+
+#if 0 // jwk: this is now done in addDecl()
+  processFuncArgs (currFunc);
+#endif
 
   /* set the stack pointer */
   /* PENDING: check this for the mcs51 */
index 32fe46922c9e6b8d960eaf5c4b87c835155c445e..3e5f763231dd49cd9c1f7c316b97c5e0a8f4b29c 100644 (file)
@@ -100,7 +100,6 @@ typedef struct ast
     sym_link *ftype;           /* start of type chain for this subtree */
     sym_link *etype;           /* end of type chain for this subtree   */
 
-    symbol *argSym;            /* argument symbols            */
     struct ast *left;          /* pointer to left tree        */
     struct ast *right;         /* pointer to right tree       */
     symbol *trueLabel;         /* if statement trueLabel */
index f947077298ce46656c6904edd44a35fd9014fc26..7dca929a28cb09708a605048325f32af70359385 100644 (file)
@@ -2112,10 +2112,8 @@ geniCodeStruct (operand * left, operand * right, bool islval)
   SPEC_OCLS (retype) = SPEC_OCLS (etype);
   SPEC_VOLATILE (retype) |= SPEC_VOLATILE (etype);
 
-#if 1 // jwk
   if (IS_PTR (element->type))
     setOperandType (IC_RESULT (ic), aggrToPtr (operandType (IC_RESULT (ic)), TRUE));
-#endif
 
   IC_RESULT (ic)->isaddr = (!IS_AGGREGATE (element->type));
 
@@ -2734,8 +2732,7 @@ geniCodeParms (ast * parms, value *argVals, int *stack,
     }
 
   /* if register parm then make it a send */
-  if ((parms->argSym && IS_REGPARM(parms->argSym->etype)) ||
-      (IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(func->type)))
+  if (IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(func->type))
     {
       ic = newiCode (SEND, pval, NULL);
       ADDTOCHAIN (ic);
index 8b95850638c54e44eb944a71e3201b9b3b27aa75..613de3e200c8b067c76dc30f4183c54bbd74b833 100644 (file)
@@ -370,7 +370,6 @@ allocGlobal (symbol * sym)
     {
       /* set the output class */
       SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
-      // jwk: we need to set SPEC_SCLS now !!!!
       /* generate the symbol  */
       allocIntoSeg (sym);
       return;
@@ -800,8 +799,9 @@ allocVariables (symbol * symChain)
       /* then args  processing  */
       if (funcInChain (csym->type))
        {
-
-         processFuncArgs (csym, 1);
+#if 1 // jwk: TODO should have been done already in addDecl() (oclass????)
+         processFuncArgs (csym);
+#endif
          /* if register bank specified then update maxRegBank */
          if (maxRegBank < FUNC_REGBANK (csym->type))
            maxRegBank = FUNC_REGBANK (csym->type);
index 7056cf7e0b10a86edfac6fb009ad7895a833a6e9..d19342b5faa11f98638a465218c0201b1f863839 100644 (file)
@@ -122,14 +122,6 @@ addSym (bucket ** stab,
     }
     /* make sure the type is complete and sane */
     checkTypeSanity(csym->etype, csym->name);
-
-    // jwk: if this is a function ptr with a void arg, remove it
-    if (IS_DECL(csym->type) && DCL_TYPE(csym->type)==CPOINTER) {
-      sym_link *type=csym->type->next;
-      if (FUNC_ARGS(type) && SPEC_NOUN(FUNC_ARGS(type)->type)==V_VOID) {
-       FUNC_ARGS(type)=NULL;
-      }
-    }
   }
 
   /* prevent overflow of the (r)name buffers */
@@ -418,6 +410,9 @@ addDecl (symbol * sym, int type, sym_link * p)
   sym_link *tail;
   sym_link *t;
 
+  if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+    fprintf (stderr, "SDCCsymt.c:addDecl(%s,%d,%p)\n", sym->name, type, p);
+
   /* if we are passed a link then set head & tail */
   if (p)
     {
@@ -480,6 +475,12 @@ addDecl (symbol * sym, int type, sym_link * p)
       SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
       DCL_TSPEC (p) = NULL;
     }
+
+  // if there is a function in this type chain
+  if (p && funcInChain(sym->type)) {
+    processFuncArgs (sym);
+  }
+
   return;
 }
 
@@ -1107,10 +1108,12 @@ 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, 1);
+           processFuncArgs (loop);
        }
+#endif
 
        loop = loop->next;
 
@@ -1770,12 +1773,20 @@ checkFunction (symbol * sym, symbol *csym)
 /* processFuncArgs - does some processing with function args       */
 /*-----------------------------------------------------------------*/
 void 
-processFuncArgs (symbol * func, int ignoreName)
+processFuncArgs (symbol * func)
 {
   value *val;
   int pNum = 1;
   sym_link *funcType=func->type;
 
+  if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+    fprintf (stderr, "SDCCsymt.c:processFuncArgs(%s)\n", func->name);
+
+  // if this is a pointer to a function
+  if (IS_PTR(funcType)) {
+    funcType=funcType->next;
+  }
+
   /* if this function has variable argument list */
   /* then make the function a reentrant one    */
   if (IFFUNC_HASVARARGS(funcType))
index 6ff6e0a72addecde9906c0d4dd7fe5f953c11a28..9aca29752c1b5d8c97a6beda6f29e3e09237898b 100644 (file)
@@ -469,7 +469,7 @@ void addSymChain (symbol *);
 sym_link *structElemType (sym_link *, value *);
 symbol *getStructElement (structdef *, symbol *);
 sym_link *computeType (sym_link *, sym_link *);
-void processFuncArgs (symbol *, int);
+void processFuncArgs (symbol *);
 int isSymbolEqual (symbol *, symbol *);
 int powof2 (unsigned long);
 void printTypeChain (sym_link *, FILE *);