changePointer(LTYPE(tree));
checkTypeSanity(LETYPE(tree), "(cast)");
+ /* if 'from' and 'to' are the same remove the superflous cast, */
+ /* this helps other optimizations */
+ if (compareTypeExact (LTYPE(tree), RTYPE(tree), -1) == 1)
+ {
+ return tree->right;
+ }
+
/* If code memory is read only, then pointers to code memory */
/* implicitly point to constants -- make this explicit */
{
goto errorTreeReturn;
}
}
+
/* if unsigned value < 0 then always false */
/* if (unsigned value) > 0 then '(unsigned value) ? 1 : 0' */
if (SPEC_USIGN(LETYPE(tree)) &&
tree->right); /* val 0 */
tree->right->lineno = tree->lineno;
tree->right->left->lineno = tree->lineno;
- decorateType (tree->right, RESULT_TYPE_NONE);
+ tree->decorated = 0;
+ return decorateType (tree, resultType);
}
}
+
+ /* 'ifx (op == 0)' -> 'ifx (!(op))' */
+ if (IS_LITERAL(RTYPE(tree)) &&
+ floatFromVal (valFromType (RETYPE (tree))) == 0 &&
+ tree->opval.op == EQ_OP &&
+ resultType == RESULT_TYPE_IFX)
+ {
+ tree->opval.op = '!';
+ tree->right = NULL;
+ tree->decorated = 0;
+ return decorateType (tree, resultType);
+ }
+
/* if they are both literal then */
/* rewrite the tree */
if (IS_LITERAL (RTYPE (tree)) &&
}
LRVAL (tree) = RRVAL (tree) = 1;
- TTYPE (tree) = TETYPE (tree) = newCharLink ();
+ TTYPE (tree) = TETYPE (tree) = newBoolLink ();
return tree;
/*------------------------------------------------------------------*/