mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
tccgen/32bits: fix unsigned long long -> int cast
gen_cast() failed to truncate long long's if they were unsigned, which was causing mess on the vstack. There was a similar bug here tccgen: 32bits: fix PTR +/- long longed15cddacd
Both were not visible until this patch tccgen: arm/i386: save_reg_upstackb691585785
I'd still assume that this patch is correct per se. Also: - remove 2x !nocode_wanted (we are already under a general "else if (!nocode_wanted)" clause above).
This commit is contained in:
parent
4ac0e1971e
commit
6245db9fca
6
tccgen.c
6
tccgen.c
@ -2315,7 +2315,7 @@ static void gen_cast(CType *type)
|
||||
}
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
} else if ((dbt & VT_BTYPE) == VT_LLONG) {
|
||||
if ((sbt & VT_BTYPE) != VT_LLONG && !nocode_wanted) {
|
||||
if ((sbt & VT_BTYPE) != VT_LLONG) {
|
||||
/* scalar to long long */
|
||||
/* machine independent conversion */
|
||||
gv(RC_INT);
|
||||
@ -2343,7 +2343,7 @@ static void gen_cast(CType *type)
|
||||
(dbt & VT_BTYPE) == VT_FUNC) {
|
||||
if ((sbt & VT_BTYPE) != VT_LLONG &&
|
||||
(sbt & VT_BTYPE) != VT_PTR &&
|
||||
(sbt & VT_BTYPE) != VT_FUNC && !nocode_wanted) {
|
||||
(sbt & VT_BTYPE) != VT_FUNC) {
|
||||
/* need to convert from 32bit to 64bit */
|
||||
gv(RC_INT);
|
||||
if (sbt != (VT_INT | VT_UNSIGNED)) {
|
||||
@ -2373,7 +2373,7 @@ static void gen_cast(CType *type)
|
||||
force_charshort_cast(dbt);
|
||||
} else if ((dbt & VT_BTYPE) == VT_INT) {
|
||||
/* scalar to int */
|
||||
if (sbt == VT_LLONG && !nocode_wanted) {
|
||||
if ((sbt & VT_BTYPE) == VT_LLONG) {
|
||||
/* from long long: just take low order word */
|
||||
lexpand();
|
||||
vpop();
|
||||
|
Loading…
Reference in New Issue
Block a user