scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 52f26ada8dedab3823cf9dc42625391830bf9619
parent 0ecbf7a103fa60948be1dfb8cd41691272bb909d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 12 Jul 2016 15:50:27 +0200

[cc2] Fix case of return without expression

eval is no longer detecting if the input token
is null, and in the case of return this
situation can happen, and it has happening.

Diffstat:
Mcc2/parser.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -329,7 +329,9 @@ oreturn(char *token, union tokenop u) { Node *np = newnode(u.op); - eval(strtok(NULL, "\t\n")); + token = strtok(NULL, "\t\n"); + if (token) + eval(strtok(NULL, "\t\n")); if (!empty()) np->left = pop(); push(np);