From c31dc7aa0c36e19e15cf41a0d2728e89ad339660 Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Tue, 31 Aug 2010 08:35:31 +0900 Subject: Fix casts from 32bit integer types to 64bit integer types. This bug was reported in http://lists.gnu.org/archive/html/tinycc-devel/2010-08/msg00050.html In this case, we should not emit any code when we cast from VT_FUNC to VT_PTR. --- tccgen.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 7d7cafc..fecaedf 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1883,12 +1883,14 @@ static void gen_cast(CType *type) } #else } else if ((dbt & VT_BTYPE) == VT_LLONG || - (dbt & VT_BTYPE) == VT_PTR) { - /* XXX: not sure if this is perfect... need more tests */ - if ((sbt & VT_BTYPE) != VT_LLONG) { + (dbt & VT_BTYPE) == VT_PTR || + (dbt & VT_BTYPE) == VT_FUNC) { + if ((sbt & VT_BTYPE) != VT_LLONG && + (sbt & VT_BTYPE) != VT_PTR && + (sbt & VT_BTYPE) != VT_FUNC) { + /* need to convert from 32bit to 64bit */ int r = gv(RC_INT); - if (sbt != (VT_INT | VT_UNSIGNED) && - sbt != VT_PTR && sbt != VT_FUNC) { + if (sbt != (VT_INT | VT_UNSIGNED)) { /* x86_64 specific: movslq */ o(0x6348); o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r)); -- cgit v1.3.1