1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

fix int const - float var

This commit is contained in:
mrdudz 2023-09-02 01:12:00 +02:00
parent fee2b834b0
commit a8e9783f1c
3 changed files with 21 additions and 14 deletions

View File

@ -94,7 +94,7 @@ NOT WORKING YET:
/test/val/float-basic-intvar-const.c -, +=, -=, *=, /=
/test/val/float-basic-intvar-var.c -, *, /, +=, /=
/test/val/float-basic-intconst-var.c -, *, /
/test/val/float-basic-intconst-var.c *, /
/test/val/float-cmp-const-intvar.c
/test/val/float-cmp-intvar-const.c

View File

@ -4018,14 +4018,14 @@ static void parsesub (ExprDesc* Expr)
} else if (IsClassFloat (lhst) && IsClassFloat (rhst)) {
/* Float substraction */
/* FIXME: float - what to do here exactly? */
LOG(("%s:%d parsesub float - float\n", __FILE__, __LINE__));
LOG(("%s:%d parsesub float - float var\n", __FILE__, __LINE__));
/* Adjust operand types */
/*flags = typeadjust (Expr, &Expr2, 0);*/
flags = CF_FLOAT;
} else if (IsClassFloat (lhst) && IsClassInt (rhst)) {
/* Float substraction */
/* FIXME: float - what to do here exactly? */
LOG(("%s:%d parsesub float - int\n", __FILE__, __LINE__));
LOG(("%s:%d parsesub float - int var\n", __FILE__, __LINE__));
#if 1
/* Adjust operand types */
flags = typeadjust (Expr, &Expr2, 0);
@ -4034,12 +4034,15 @@ static void parsesub (ExprDesc* Expr)
} else if (IsClassInt (lhst) && IsClassFloat (rhst)) {
/* Float substraction */
/* FIXME: float - what to do here exactly? */
LOG(("FIXME: %s:%d parsesub int - float\n", __FILE__, __LINE__));
#if 0
/* Adjust operand types */
/*flags = typeadjust (Expr, &Expr2, 0);*/
flags = CF_FLOAT;
LOG(("FIXME: %s:%d parsesub int - float var\n", __FILE__, __LINE__));
#if 1
/* Remove pushed value from stack */
RemoveCode (&Mark2);
flags = typeadjust (&Expr2, Expr, 0);
g_push (CF_FLOAT, 0); /* --> stack */
LoadExpr (CF_FLOAT, &Expr2); /* --> primary register */
#endif
} else {
/* OOPS */
Error ("Invalid operands for binary operator '-'");
@ -4052,8 +4055,12 @@ static void parsesub (ExprDesc* Expr)
ED_FinalizeRValLoad (Expr);
}
/* Result type is either a pointer or an integer */
Expr->Type = StdConversion (Expr->Type);
if (IsClassFloat (lhst) || IsClassFloat (rhst)) {
Expr->Type = type_float;
} else {
/* Result type is either a pointer or an integer */
Expr->Type = StdConversion (Expr->Type);
}
/* Condition code not set */
ED_MarkAsUntested (Expr);

View File

@ -83,11 +83,11 @@ void intconstvar(void)
printf("fp1:0x%08lx [?] %s (58.123)", *((uint32_t*)&fp1), _ftostr(buf, fp1));
test1(fp1, "42687df4");
#if 0 // Invalid operands for binary operator '-'
fp1 = 47 - var_float;
printf("fp1:0x%08lx [?] %s (58.123)", *((uint32_t*)&fp1), _ftostr(buf, fp1));
test1(fp1, "42687df4");
#endif
printf("fp1:0x%08lx [?] %s (35.877)", *((uint32_t*)&fp1), _ftostr(buf, fp1));
test1(fp1, "420f820c");
#if 0 // compiles, but wrong result
fp1 = 47 * var_float;
printf("fp1:0x%08lx [?] %s (522.781)", *((uint32_t*)&fp1), _ftostr(buf, fp1));