This happens to be needed for C. The standard mandates that a return value is used if the caller uses it. Surprisingly, if the return "value" is not used, the callee can use "return;". A better solution is to add an "undef" value and return it, "undef" would also have other use cases for compiling C.
Showing the changes to parse.c (1 of 1 file). Show all
Unified · Split
| @@ -545,10 +545,12 @@ parseline(PState ps) · 544 unmodified lines | |||
| 545 | Jrets, Jretd, | 545 | Jrets, Jretd, |
| 546 | Jretc, Jret0 | 546 | Jretc, Jret0 |
| 547 | }[rcls]; | 547 | }[rcls]; |
| 548 | if (rcls < 5) { | 548 | if (peek() == Tnl) |
| 549 | curb->jmp.type = Jret0; | ||
| 550 | else if (rcls < 5) { | ||
| 549 | r = parseref(); | 551 | r = parseref(); |
| 550 | if (req(r, R)) | 552 | if (req(r, R)) |
| 551 | err("return value expected"); | 553 | err("invalid return value"); |
| 552 | curb->jmp.arg = r; | 554 | curb->jmp.arg = r; |
| 553 | } | 555 | } |
| 554 | goto Close; | 556 | goto Close; |