Unified · Split
| @@ -2412,8 +2412,20 @@ static void gen_assign_cast(CType *dt) · 2411 unmodified lines | ||
| 2412 | 2412 | st = &vtop->type; /* source type */ |
| 2413 | 2413 | dbt = dt->t & VT_BTYPE; |
| 2414 | 2414 | sbt = st->t & VT_BTYPE; |
| 2415 | − if (sbt == VT_VOID || dbt == VT_VOID) | |
| 2416 | − tcc_error("cannot cast from/to void"); | |
| 2415 | + if (sbt == VT_VOID || dbt == VT_VOID) { | |
| 2416 | + if (sbt == VT_VOID && dbt == VT_VOID) | |
| 2417 | + ; /* | |
| 2418 | + It is Ok if both are void | |
| 2419 | + A test program: | |
| 2420 | + void func1() {} | |
| 2421 | + void func2() { | |
| 2422 | + return func1(); | |
| 2423 | + } | |
| 2424 | + gcc accepts this program | |
| 2425 | + */ | |
| 2426 | + else | |
| 2427 | + tcc_error("cannot cast from/to void"); | |
| 2428 | + } | |
| 2417 | 2429 | if (dt->t & VT_CONSTANT) |
| 2418 | 2430 | tcc_warning("assignment of read-only location"); |
| 2419 | 2431 | switch(dbt) { |