if (processParms (tree->left,
FUNC_ARGS(tree->left->ftype),
tree->right, &parmNumber, TRUE)) {
- //fprintf (stderr, "jwk: error in processParms()\n");
goto errorTreeReturn;
}
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;
}
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 */
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 */
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));
}
/* 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);
{
/* 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;
/* 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);
}
/* 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 */
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)
{
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;
}
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;
/* 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))
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 *);