diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-09-27 10:23:31 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-09-27 10:23:31 -0400 |
commit | fd9c2e045f7cc953bebab2e2e65da9cd73b04f17 (patch) | |
tree | 3412d44844f6f77c19cadc2de1d74856db4ecc42 | |
parent | 09192cdeabeb185e54d60faa2b275a0e8e2a52a6 (diff) | |
download | roux-fd9c2e045f7cc953bebab2e2e65da9cd73b04f17.tar.gz |
accept "ret" for functions with a return type
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.
-rw-r--r-- | parse.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/parse.c b/parse.c index 31a6d09..f70bbc2 100644 --- a/parse.c +++ b/parse.c @@ -545,10 +545,12 @@ parseline(PState ps) Jrets, Jretd, Jretc, Jret0 }[rcls]; - if (rcls < 5) { + if (peek() == Tnl) + curb->jmp.type = Jret0; + else if (rcls < 5) { r = parseref(); if (req(r, R)) - err("return value expected"); + err("invalid return value"); curb->jmp.arg = r; } goto Close; |