riscv: fix more sign/zero-extension problems

see the testcase.  For the signed case this problably does
the wrong thing, and it should break other archs.  Rework once
there are testcases for this.
This commit is contained in:
Michael Matz 2019-07-22 06:45:03 +02:00
parent 1ada32900b
commit 509f561823
2 changed files with 14 additions and 7 deletions

View File

@ -2867,12 +2867,15 @@ static void gen_cast(CType *type)
lexpand();
vpop();
#else
/* XXX some architectures (e.g. risc-v) would like it
better for this merely being a 32-to-64 sign or zero-
extension. */
vpushi(0xffffffff);
vtop->type.t |= VT_UNSIGNED;
gen_op('&');
if (dbt & VT_UNSIGNED) {
/* XXX some architectures (e.g. risc-v) would like it
better for this merely being a 32-to-64 sign or zero-
extension. */
vpushi(0xffffffff);
vtop->type.t |= VT_UNSIGNED;
gen_op('&');
} else {
}
#endif
}
/* if lvalue and single word type, nothing to do because
@ -5253,7 +5256,7 @@ ST_FUNC void unary(void)
vtop->c.f = -1.0 * 0.0;
else if (t == VT_DOUBLE)
vtop->c.d = -1.0 * 0.0;
else
else
vtop->c.ld = -1.0 * 0.0;
} else
vpushi(0);

View File

@ -1633,6 +1633,7 @@ void cast_test()
unsigned b,d;
short s;
char *p = NULL;
unsigned long ul = 0x80000000UL;
p -= 0x700000000042;
printf("cast_test:\n");
@ -1685,6 +1686,9 @@ void cast_test()
/* from integers to pointers */
printf("%p %p %p %p\n",
(void *)a, (void *)b, (void *)c, (void *)d);
/* int to int with sign set */
printf("0x%lx\n", (unsigned long)(int)ul);
}
/* initializers tests */