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
3 changed files with 13 additions and 9 deletions
5
tccgen.c
5
tccgen.c
|
@ -3573,6 +3573,11 @@ again:
|
||||||
/* ss <= 4 here */
|
/* ss <= 4 here */
|
||||||
if (ds <= 4) {
|
if (ds <= 4) {
|
||||||
gv(RC_INT);
|
gv(RC_INT);
|
||||||
|
if (ds == 2 && (dbt & VT_UNSIGNED) &&
|
||||||
|
ss == 1 && (sbt & VT_UNSIGNED) == 0) {
|
||||||
|
vpushi(0xffff);
|
||||||
|
gen_op('&');
|
||||||
|
}
|
||||||
goto done; /* no 64bit envolved */
|
goto done; /* no 64bit envolved */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.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;
|
typedef struct{double x,y;}p;
|
||||||
|
|
||||||
void tst2(int n,...)
|
void tst2(int n,...)
|
||||||
|
@ -69,7 +61,6 @@ int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
p v = { 1, 2};
|
p v = { 1, 2};
|
||||||
tst1();
|
|
||||||
tst2(1, v);
|
tst2(1, v);
|
||||||
tst3();
|
tst3();
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,13 @@ void tst_pack (void)
|
||||||
if (j.f != i.f) printf("error\n");
|
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
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
@ -155,4 +162,5 @@ main (void)
|
||||||
tst_builtin();
|
tst_builtin();
|
||||||
tst_compare();
|
tst_compare();
|
||||||
tst_pack();
|
tst_pack();
|
||||||
|
tst_cast();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue