+2005-07-16 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCcse.c (algebraicOpts): fixed loss of volatility
+ for fields at offset 0 of a struct or union as reported
+ on 2005-07-07 in the developer mailing list.
+
2005-07-15 Maarten Brock <sourceforge.brock AT dse.nl>
* src/SDCCmem.c: fixed bug 1238386
if (IS_OP_LITERAL (IC_LEFT (ic)) &&
operandLitValue (IC_LEFT (ic)) == 0.0)
{
- if (compareType (operandType (IC_RESULT (ic)),
- operandType (IC_RIGHT (ic)))<0)
+ int typematch;
+ typematch = compareType (operandType (IC_RESULT (ic)),
+ operandType (IC_RIGHT (ic)));
+ if (typematch<0)
{
ic->op = CAST;
IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic)));
{
ic->op = '=';
IC_LEFT (ic) = NULL;
+ if (typematch==0)
+ {
+ /* for completely different types, preserve the source type */
+ IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic));
+ setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic)));
+ }
}
SET_ISADDR (IC_RESULT (ic), 0);
SET_ISADDR (IC_RIGHT (ic), 0);
if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
operandLitValue (IC_RIGHT (ic)) == 0.0)
{
- if (compareType (operandType (IC_RESULT (ic)),
- operandType (IC_LEFT (ic)))<0)
+ int typematch;
+ typematch = compareType (operandType (IC_RESULT (ic)),
+ operandType (IC_LEFT (ic)));
+ if (typematch<0)
{
ic->op = CAST;
IC_RIGHT (ic) = IC_LEFT (ic);
ic->op = '=';
IC_RIGHT (ic) = IC_LEFT (ic);
IC_LEFT (ic) = NULL;
+ if (typematch==0)
+ {
+ /* for completely different types, preserve the source type */
+ IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic));
+ setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic)));
+ }
}
SET_ISADDR (IC_RIGHT (ic), 0);
SET_ISADDR (IC_RESULT (ic), 0);