mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-28 08:10:25 +08:00
Fix negation of 0.0 and -0.0
This commit is contained in:
parent
0382131c6f
commit
3eed3506b4
17
tccgen.c
17
tccgen.c
@ -3794,9 +3794,22 @@ ST_FUNC void unary(void)
|
|||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
next();
|
next();
|
||||||
vpushi(0);
|
|
||||||
unary();
|
unary();
|
||||||
gen_op('-');
|
t = vtop->type.t & VT_BTYPE;
|
||||||
|
/* handle (-)0.0 */
|
||||||
|
if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST &&
|
||||||
|
is_float(t)) {
|
||||||
|
if (t == VT_FLOAT)
|
||||||
|
vtop->c.f = -vtop->c.f;
|
||||||
|
else if (t == VT_DOUBLE)
|
||||||
|
vtop->c.d = -vtop->c.d;
|
||||||
|
else
|
||||||
|
vtop->c.ld = -vtop->c.ld;
|
||||||
|
} else {
|
||||||
|
vpushi(0);
|
||||||
|
vswap();
|
||||||
|
gen_op('-');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TOK_LAND:
|
case TOK_LAND:
|
||||||
if (!gnu_ext)
|
if (!gnu_ext)
|
||||||
|
Loading…
Reference in New Issue
Block a user