From 12f03839203199558b184b3718d53936fc0daa19 Mon Sep 17 00:00:00 2001 From: johanknol Date: Mon, 29 Oct 2001 10:29:22 +0000 Subject: [PATCH] fixed an array to pointer bug cleaned it up a little unified print from -> to typechain git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1462 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCast.c | 23 ++++------------------- src/SDCCicode.c | 15 +++------------ src/SDCCsymt.c | 25 +++++++++++-------------- src/SDCCsymt.h | 5 +++-- 4 files changed, 21 insertions(+), 47 deletions(-) diff --git a/src/SDCCast.c b/src/SDCCast.c index 2cc429de..aa992710 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -739,12 +739,7 @@ processParms (ast * func, /* the parameter type must be at least castable */ if (compareType (defParm->type, actParm->ftype) == 0) { werror (E_INCOMPAT_TYPES); - fprintf (stderr, "type --> '"); - printTypeChain (actParm->ftype, stderr); - fprintf (stderr, "' "); - fprintf (stderr, "assigned to type --> '"); - printTypeChain (defParm->type, stderr); - fprintf (stderr, "'\n"); + printFromToType (actParm->ftype, defParm->type); return 1; } @@ -791,6 +786,7 @@ ast * createIvalStruct (ast * sym, sym_link * type, initList * ilist) { ast *rast = NULL; + ast *lAst; symbol *sflds; initList *iloop; @@ -805,8 +801,6 @@ createIvalStruct (ast * sym, sym_link * type, initList * ilist) for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) { - ast *lAst; - /* if we have come to end */ if (!iloop) break; @@ -3052,12 +3046,7 @@ decorateType (ast * tree) if (IS_VOID (LTYPE (tree))) { werror (E_CAST_ZERO); - fprintf (stderr, "type --> '"); - printTypeChain (RTYPE (tree), stderr); - fprintf (stderr, "' "); - fprintf (stderr, "assigned to type --> '"); - printTypeChain (LTYPE (tree), stderr); - fprintf (stderr, "'\n"); + printFromToType(RTYPE(tree), LTYPE(tree)); } TETYPE (tree) = getSpec (TTYPE (tree) = @@ -3117,11 +3106,7 @@ decorateType (ast * tree) if (compareType (currFunc->type->next, RTYPE (tree)) == 0) { werror (W_RETURN_MISMATCH); - fprintf (stderr, "from type '"); - printTypeChain (RTYPE(tree), stderr); - fprintf (stderr, "' to type '"); - printTypeChain (currFunc->type->next, stderr); - fprintf (stderr, "'\n"); + printFromToType (RTYPE(tree), currFunc->type->next); goto errorTreeReturn; } diff --git a/src/SDCCicode.c b/src/SDCCicode.c index fc950632..297ed3a7 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1658,13 +1658,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) } } if (errors) { - /* fprintf (stderr, "%s%s %d: ", op->operand.symOperand->name, - implicit?"(implicit)":"", errors); */ - fprintf (stderr, "from type '"); - printTypeChain (optype, stderr); - fprintf (stderr, "' to type '"); - printTypeChain (type, stderr); - fprintf (stderr, "'\n"); + printFromToType (optype, type); } /* if they are the same size create an assignment */ @@ -2118,8 +2112,10 @@ 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)); @@ -2710,11 +2706,6 @@ geniCodeParms (ast * parms, value *argVals, int *stack, argVals=FUNC_ARGS(func->type); } - if (parms->argSym || - (parms->type!=EX_OP && parms->type!=EX_OPERAND)) { - fprintf (stderr, "What the fuck??\n"); - } - /* if this is a param node then do the left & right */ if (parms->type == EX_OP && parms->opval.op == PARAM) { diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index e0a94215..0a5767de 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -26,6 +26,14 @@ value *aggregateToPointer (value *val); +void printFromToType(sym_link *from, sym_link *to) { + fprintf (stderr, "from type '"); + printTypeChain (from, stderr); + fprintf (stderr, "'\nto type '"); + printTypeChain (to, stderr); + fprintf (stderr, "'\n"); +} + /* noun strings */ char *nounName(sym_link *sl) { switch (SPEC_NOUN(sl)) @@ -545,10 +553,6 @@ mergeSpec (sym_link * dest, sym_link * src, char *name) exit (1); } - if (getenv("DEBUG_mergeSpec")) { - fprintf (stderr, "mergeSpec: \"%s\"\n", name); - } - if (SPEC_NOUN(src)) { if (!SPEC_NOUN(dest)) { SPEC_NOUN(dest)=SPEC_NOUN(src); @@ -1119,9 +1123,6 @@ checkSClass (symbol * sym, int isProto) if (getenv("DEBUG_SANITY")) { fprintf (stderr, "checkSClass: %s \n", sym->name); } - if (strcmp(sym->name, "_testsGlobal")==0) { - printf ("oach\n"); - } /* type is literal can happen foe enums change to auto */ @@ -1563,8 +1564,8 @@ aggregateToPointer (value * val) case S_FIXED: if (SPEC_OCLS(val->etype)) { DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype)); + break; } - break; if (TARGET_IS_DS390) { @@ -1675,12 +1676,7 @@ checkFunction (symbol * sym, symbol *csym) if (compareType (csym->type, sym->type) <= 0) { werror (E_PREV_DEF_CONFLICT, csym->name, "type"); - werror (W_CONTINUE, "previous definition type "); - printTypeChain (csym->type, stderr); - fprintf (stderr, "\n"); - werror (W_CONTINUE, "current definition type "); - printTypeChain (sym->type, stderr); - fprintf (stderr, "\n"); + printFromToType(csym->type, sym->type); return 0; } @@ -1731,6 +1727,7 @@ checkFunction (symbol * sym, symbol *csym) if (compareType (exargs->type, checkValue->type) <= 0) { werror (E_ARG_TYPE, argCnt); + printFromToType(exargs->type, checkValue->type); return 0; } } diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 12e76466..6ff6e0a7 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -487,7 +487,8 @@ void *findSymWithLevel (bucket **, struct symbol *); void *findSymWithBlock (bucket **, struct symbol *, int); void changePointer (symbol * sym); void checkTypeSanity(sym_link *etype, char *name); -/* noun strings */ -extern char *nounName(sym_link *); + +extern char *nounName(sym_link *); /* noun strings */ +extern void printFromToType (sym_link *, sym_link *); #endif -- 2.30.2