shithub: scc

Download patch

ref: 1cd7549a09f4c1d125bb04a641aab05a83e5f2b9
parent: 7d32c5733f318b04aefa28e3738bebcad8323b6a
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Jul 9 14:27:22 EDT 2014

Simplify Return()

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