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 long
    ed15cddacd

Both were not visible until this patch
    tccgen: arm/i386: save_reg_upstack
    b691585785

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).
master
grischka 2016-10-16 11:03:57 +02:00
parent 4ac0e1971e
commit 6245db9fca
1 changed files with 3 additions and 3 deletions

View File

@ -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();