From: bernhardheld Date: Sun, 11 Jan 2004 21:58:32 +0000 (+0000) Subject: * src/SDCCast.c (decorateType): fixed char foo (unsigned long ul) { return ul > 0; } X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=456783df6bd8033fa8bcfb2ce3dfa1c462f8046a;p=fw%2Fsdcc * src/SDCCast.c (decorateType): fixed char foo (unsigned long ul) { return ul > 0; } git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3116 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 03476aac..0d8dd809 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2004-01-11 Bernhard Held * src/SDCCicode.c (operandOperation): fixed bug #874819 + * src/SDCCast.c (decorateType): fixed + char foo (unsigned long ul) { return ul > 0; } 2004-01-11 Frieder Ferlemann diff --git a/src/SDCCast.c b/src/SDCCast.c index 9944eb40..c1ed4b04 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1746,7 +1746,7 @@ isConformingBody (ast * pbody, symbol * sym, ast * body) case '?': case ':': case SIZEOF: /* evaluate wihout code generation */ - + if (IS_AST_SYM_VALUE (pbody->left) && isSymbolEqual (AST_SYMBOL (pbody->left), sym)) return FALSE; @@ -3478,7 +3478,7 @@ decorateType (ast * tree) } } /* if unsigned value < 0 then always false */ - /* if (unsigned value) > 0 then (unsigned value) */ + /* if (unsigned value) > 0 then '(unsigned value) ? 1 : 0' */ if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) && ((int) floatFromVal (valFromType (RETYPE (tree)))) == 0) { @@ -3488,7 +3488,13 @@ decorateType (ast * tree) } if (tree->opval.op == '>') { - return tree->left; + tree->opval.op = '?'; + tree->right = newNode (':', + newAst_VALUE (constVal ("1")), + tree->right); /* val 0 */ + tree->right->lineno = tree->lineno; + tree->right->left->lineno = tree->lineno; + decorateType (tree->right); } } /* if they are both literal then */