Update casted boolean expressions
The problem was that enums can also be present in vset_VT_JMP. Also see testcode.
This commit is contained in:
parent
ef3eb02ccb
commit
88d5c70bdb
2 changed files with 9 additions and 1 deletions
2
tccgen.c
2
tccgen.c
|
@ -934,7 +934,7 @@ static void vset_VT_JMP(void)
|
|||
/* we need to jump to 'mov $0,%R' or 'mov $1,%R' */
|
||||
int inv = op & (op < 2); /* small optimization */
|
||||
vseti(VT_JMP+inv, gvtst(inv, 0));
|
||||
vtop->type.t = origt;
|
||||
vtop->type.t |= origt & (VT_UNSIGNED | VT_DEFSIGN);
|
||||
} else {
|
||||
/* otherwise convert flags (rsp. 0/1) to register */
|
||||
vtop->c.i = op;
|
||||
|
|
|
@ -1220,6 +1220,13 @@ static unsigned int calc_vm_flags(unsigned int prot)
|
|||
return prot_bits;
|
||||
}
|
||||
|
||||
enum cast_enum { FIRST, LAST };
|
||||
|
||||
static void tst_cast(enum cast_enum ce)
|
||||
{
|
||||
printf("%d\n", ce);
|
||||
}
|
||||
|
||||
void bool_test()
|
||||
{
|
||||
int *s, a, b, t, f, i;
|
||||
|
@ -1268,6 +1275,7 @@ void bool_test()
|
|||
/* check that types of casted &&/|| are preserved (here the unsignedness) */
|
||||
t = 1;
|
||||
printf("type of bool: %d\n", (int) ( (~ ((unsigned int) (t && 1))) / 2) );
|
||||
tst_cast(t >= 0 ? FIRST : LAST);
|
||||
|
||||
printf("type of cond: %d\n", (~(t ? 0U : (unsigned int)0)) / 2 );
|
||||
/* test ? : cast */
|
||||
|
|
Loading…
Reference in a new issue