value *defParm,
ast * actParm,
int *parmNumber, // unused, although updated
- bool rightmost) // double checked?
+ bool rightmost)
{
/* if none of them exist */
if (!defParm && !actParm)
actParm->right = pTree;
actParm->etype = defParm->etype;
actParm->ftype = defParm->type;
+ actParm->decorated=0; /* force typechecking */
+ decorateType (actParm);
}
/* make a copy and change the regparm type to the defined parm */
LRVAL (tree) = 1;
}
#else
+ /* if pointer to struct then check names */
+ if (IS_PTR(LTYPE(tree)) && IS_STRUCT(LTYPE(tree)->next) &&
+ IS_PTR(RTYPE(tree)) && IS_STRUCT(RTYPE(tree)->next) &&
+ strcmp(SPEC_STRUCT(LETYPE(tree))->tag,SPEC_STRUCT(RETYPE(tree))->tag)) {
+ werror(W_CAST_STRUCT_PTR,SPEC_STRUCT(RETYPE(tree))->tag,SPEC_STRUCT(LETYPE(tree))->tag);
+ }
/* if the right is a literal replace the tree */
if (IS_LITERAL (RETYPE (tree)) && !IS_PTR (LTYPE (tree))) {
tree->type = EX_VALUE;
TTYPE (tree) = LTYPE (tree);
LRVAL (tree) = 1;
}
-#endif
-
+#endif
TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
if (processParms (tree->left,
FUNC_ARGS(tree->left->ftype),
- tree->right, &parmNumber, TRUE))
+ tree->right, &parmNumber, TRUE)) {
goto errorTreeReturn;
+ }
if (options.stackAuto || IFFUNC_ISREENT (LTYPE (tree)))
{
- //IFFUNC_ARGS(tree->left->ftype) =
- //reverseVal (IFFUNC_ARGS(tree->left->ftype));
+ //FUNC_ARGS(tree->left->ftype) =
+ //reverseVal (FUNC_ARGS(tree->left->ftype));
reverseParms (tree->right);
}
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 */
body = resolveSymbols (body); /* resolve the symbols */
body = decorateType (body); /* propagateType & do semantic checks */
- ex = newAst_VALUE (symbolVal (name)); /* create name */
+ ex = newAst_VALUE (symbolVal (name)); /* create name */
ex = newNode (FUNCTION, ex, body);
ex->values.args = FUNC_ARGS(name->type);
ex->decorated=1;
if (arg) {
fprintf (outfile, ", ");
}
- printTypeChain (args->type, outfile);
+ printTypeChain (args ? args->type : NULL, outfile);
arg++;
- args=args->next;
+ args= args ? args->next : NULL;
} while (args);
fprintf(outfile,")\n");
ast_print(tree->left,outfile,indent);
ast_print(tree->right,outfile,indent+4);
return;
case PARAM:
- fprintf(outfile,"PARM ");
+ fprintf(outfile,"PARMS\n");
ast_print(tree->left,outfile,indent+4);
if (tree->right && !IS_AST_PARAM(tree->right)) {
- fprintf(outfile,"PARM ");
ast_print(tree->right,outfile,indent+4);
}
return ;