scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 1cd7549a09f4c1d125bb04a641aab05a83e5f2b9
parent 7d32c5733f318b04aefa28e3738bebcad8323b6a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  9 Jul 2014 18:27:22 +0200

Simplify Return()

Diffstat:
cc1/expr.c | 2++
cc1/stmt.c | 2+-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -72,6 +72,8 @@ chklvalue(Node *np, Type *tp) Node * eval(Node *np) { + if (!np) + return NULL; if (!ISNODECMP(np)) return np; return ternarycode(np, symcode(one), symcode(zero)); diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -139,7 +139,7 @@ Return(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) Type *tp = curfun->type->type; expect(RETURN); - np = (yytoken == ';') ? NULL : eval(expr()); + np = eval(expr()); expect(';'); if (!np) { if (tp != voidtype)