ref: e62508a51069116eeb35fee1e774794604dae8eb
parent: d555aa6e04f4459fd6bc5f8e1fb07f80cdc29b50
author: Ori Bernstein <[email protected]>
date: Fri Jul 20 14:18:22 EDT 2012
Don't die if we call fold() on NULL. Making it safe to call fold(NULL) is easier than adding checks wrapping all call sites.
--- a/opt/fold.c
+++ b/opt/fold.c
@@ -50,6 +50,8 @@
vlong a, b;
size_t i;
+ if (!n)
+ return NULL;
assert(n->type == Nexpr);
r = NULL;
args = n->expr.args;
@@ -111,6 +113,12 @@
case Oneg:
if (islit(args[0], &a))
r = val(n->line, -a);
+ break;
+ case Ocast:
+ /* FIXME: we currentl assume that the bits of the
+ * val are close enough. */
+ r = args[0];
+ r->expr.type = exprtype(n);
break;
default:
break;