aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-03-03 15:39:57 +0300
committerseyko <seyko2@gmail.com>2015-03-03 15:39:57 +0300
commit6fd4e5bace73a260ab45a12f5588aa7bd3431f49 (patch)
tree30e18b28e42a2454ef46582b160c7e53d4b67ae0
parent09feeca5dffd3d369a8996ef68f66334d4d2c637 (diff)
downloadtinycc-6fd4e5bace73a260ab45a12f5588aa7bd3431f49.tar.gz
tinycc-6fd4e5bace73a260ab45a12f5588aa7bd3431f49.tar.bz2
a void to void cast.
Allow tcc to compile the following program /////// void func1() {} void func2() { return func1(); } ////// gcc accepts this program
-rw-r--r--tccgen.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tccgen.c b/tccgen.c
index 5556f85..6432ebb 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2412,8 +2412,20 @@ static void gen_assign_cast(CType *dt)
st = &vtop->type; /* source type */
dbt = dt->t & VT_BTYPE;
sbt = st->t & VT_BTYPE;
- if (sbt == VT_VOID || dbt == VT_VOID)
- tcc_error("cannot cast from/to void");
+ if (sbt == VT_VOID || dbt == VT_VOID) {
+ if (sbt == VT_VOID && dbt == VT_VOID)
+ ; /*
+ It is Ok if both are void
+ A test program:
+ void func1() {}
+ void func2() {
+ return func1();
+ }
+ gcc accepts this program
+ */
+ else
+ tcc_error("cannot cast from/to void");
+ }
if (dt->t & VT_CONSTANT)
tcc_warning("assignment of read-only location");
switch(dbt) {