mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
Fix shortening casts of long long
see added testcase.
This commit is contained in:
parent
c41caac02d
commit
f0a25ca263
8
tccgen.c
8
tccgen.c
@ -2633,18 +2633,22 @@ static void gen_cast(CType *type)
|
|||||||
tcc_warning("nonportable conversion from pointer to char/short");
|
tcc_warning("nonportable conversion from pointer to char/short");
|
||||||
}
|
}
|
||||||
force_charshort_cast(dbt);
|
force_charshort_cast(dbt);
|
||||||
#if PTR_SIZE == 4
|
|
||||||
} else if ((dbt & VT_BTYPE) == VT_INT) {
|
} else if ((dbt & VT_BTYPE) == VT_INT) {
|
||||||
/* scalar to int */
|
/* scalar to int */
|
||||||
if ((sbt & VT_BTYPE) == VT_LLONG) {
|
if ((sbt & VT_BTYPE) == VT_LLONG) {
|
||||||
|
#if PTR_SIZE == 4
|
||||||
/* from long long: just take low order word */
|
/* from long long: just take low order word */
|
||||||
lexpand();
|
lexpand();
|
||||||
vpop();
|
vpop();
|
||||||
|
#else
|
||||||
|
vpushi(0xffffffff);
|
||||||
|
vtop->type.t |= VT_UNSIGNED;
|
||||||
|
gen_op('&');
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* if lvalue and single word type, nothing to do because
|
/* if lvalue and single word type, nothing to do because
|
||||||
the lvalue already contains the real type size (see
|
the lvalue already contains the real type size (see
|
||||||
VT_LVAL_xxx constants) */
|
VT_LVAL_xxx constants) */
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((dbt & VT_BTYPE) == VT_PTR && !(vtop->r & VT_LVAL)) {
|
} else if ((dbt & VT_BTYPE) == VT_PTR && !(vtop->r & VT_LVAL)) {
|
||||||
|
@ -2491,6 +2491,11 @@ void longlong_test(void)
|
|||||||
a = 0x123;
|
a = 0x123;
|
||||||
long long *p = &a;
|
long long *p = &a;
|
||||||
llshift(*p, 5);
|
llshift(*p, 5);
|
||||||
|
|
||||||
|
/* shortening followed by widening */
|
||||||
|
unsigned long long u = 0x8000000000000001ULL;
|
||||||
|
u = (unsigned)(u + 1);
|
||||||
|
printf("long long u=" ULONG_LONG_FORMAT "\n", u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void manyarg_test(void)
|
void manyarg_test(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user