From: bernhardheld Date: Wed, 2 Jan 2002 22:54:25 +0000 (+0000) Subject: * src/SDCCast.c: fix #498138 by Johan X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=03b4af244de23fbad1574ec76a22305e4d7f91a0;p=fw%2Fsdcc * src/SDCCast.c: fix #498138 by Johan * src/SDCCglue.c: fix #498138 by Johan git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1756 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ba4ad491..aed8131a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-01-02 Bernhard Held + + * src/SDCCast.c: fix #498138 by Johan + + * src/SDCCglue.c: fix #498138 by Johan + 2001-01-02 Bernhard Held * support/regression/Makefile: fix clean diff --git a/src/SDCCast.c b/src/SDCCast.c index 26cd0353..85ea2852 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1236,9 +1236,9 @@ constExprValue (ast * cexpr, int check) /* if we are casting a literal value then */ if (IS_AST_OP (cexpr) && cexpr->opval.op == CAST && - IS_LITERAL (cexpr->left->ftype)) + IS_LITERAL (cexpr->right->ftype)) return valCastLiteral (cexpr->ftype, - floatFromVal (cexpr->left->opval.val)); + floatFromVal (cexpr->right->opval.val)); if (IS_AST_VALUE (cexpr)) return cexpr->opval.val; @@ -3095,13 +3095,8 @@ decorateType (ast * tree) if (compareType (LTYPE (tree), RTYPE (tree)) == 0) { werror (E_TYPE_MISMATCH, "assignment", " "); - fprintf (stderr, "type --> '"); - printTypeChain (RTYPE (tree), stderr); - fprintf (stderr, "' "); - fprintf (stderr, "assigned to type --> '"); - printTypeChain (LTYPE (tree), stderr); - fprintf (stderr, "'\n"); - goto errorTreeReturn; + printFromToType(RTYPE(tree),LTYPE(tree)); + //goto errorTreeReturn; } /* if the left side of the tree is of type void diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 748f6848..20890034 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -794,6 +794,16 @@ printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile) int dLvl = 0; val = list2val (ilist); + + if (IS_LITERAL(val->etype)) { + if (compareType(type,val->etype)==0) { + werror (E_INCOMPAT_TYPES); + printFromToType (val->type, type); + } + printIvalCharPtr (NULL, type, val, oFile); + return; + } + /* check the types */ if ((dLvl = compareType (val->type, type->next)) <= 0) { @@ -893,8 +903,8 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile) aopLiteral (val, 0), aopLiteral (val, 1)); break; case 3: - // mcs51 generic pointer - if (floatFromVal(val)!=0) { + if (IS_GENPTR(type) && floatFromVal(val)!=0) { + // non-zero mcs51 generic pointer werror (E_LITERAL_GENERIC); } fprintf (oFile, "\t.byte %s,%s,%s\n", @@ -903,8 +913,8 @@ printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile) aopLiteral (val, 2)); break; case 4: - // ds390 generic pointer - if (floatFromVal(val)!=0) { + if (IS_GENPTR(type) && floatFromVal(val)!=0) { + // non-zero ds390 generic pointer werror (E_LITERAL_GENERIC); } fprintf (oFile, "\t.byte %s,%s,%s,%s\n",