mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-13 05:10:07 +08:00
Fix char to ushort cast
tccgen.c: - gen_cast: add check for char to ushort cast tests/bug.c: - remove tst1 tests/tests2/117_gcc_test.c: - add tst_cast
This commit is contained in:
parent
696b765437
commit
a34a9775ba
5
tccgen.c
5
tccgen.c
@ -3573,6 +3573,11 @@ again:
|
||||
/* ss <= 4 here */
|
||||
if (ds <= 4) {
|
||||
gv(RC_INT);
|
||||
if (ds == 2 && (dbt & VT_UNSIGNED) &&
|
||||
ss == 1 && (sbt & VT_UNSIGNED) == 0) {
|
||||
vpushi(0xffff);
|
||||
gen_op('&');
|
||||
}
|
||||
goto done; /* no 64bit envolved */
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void tst1(void)
|
||||
{
|
||||
/* problem in gen_cast. Should mask unsigned types */
|
||||
signed char c = (signed char) 0xffffffff;
|
||||
int r = (unsigned short) c ^ (signed char) 0x99999999;
|
||||
if (r != 0xffff0066) printf ("%x\n", r);
|
||||
}
|
||||
|
||||
typedef struct{double x,y;}p;
|
||||
|
||||
void tst2(int n,...)
|
||||
@ -69,7 +61,6 @@ int
|
||||
main(void)
|
||||
{
|
||||
p v = { 1, 2};
|
||||
tst1();
|
||||
tst2(1, v);
|
||||
tst3();
|
||||
}
|
||||
|
@ -139,6 +139,13 @@ void tst_pack (void)
|
||||
if (j.f != i.f) printf("error\n");
|
||||
}
|
||||
|
||||
void tst_cast(void)
|
||||
{
|
||||
signed char c = (signed char) 0xaaaaaaaa;
|
||||
int r = (unsigned short) c ^ (signed char) 0x99999999;
|
||||
if (r != 0xffff0033) printf ("%x\n", r);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@ -155,4 +162,5 @@ main (void)
|
||||
tst_builtin();
|
||||
tst_compare();
|
||||
tst_pack();
|
||||
tst_cast();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user