summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-15 00:11:44 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-15 00:11:44 -0800
commit994b042eac3300dd62bbbc7dedbb6d9a0b525638 (patch)
tree79d2ac32ff3d01168ddd270a77aecd3a41b0f2dc /6/simp.c
parent64a7a7346e02999cf451ee45220b86ba7c69c56f (diff)
downloadmc-994b042eac3300dd62bbbc7dedbb6d9a0b525638.tar.gz
More fixes to void values.
We now unbreak varargs, and compare them correctly.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/6/simp.c b/6/simp.c
index 862aac8..c0f3619 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -963,6 +963,9 @@ static Node *assign(Simp *s, Node *lhs, Node *rhs)
t = lval(s, lhs);
u = rval(s, rhs, t);
+ if (tybase(exprtype(lhs))->type == Tyvoid)
+ return u;
+
/* hack: we're assigning to lhs, but blitting shit over doesn't
* trigger that */
if (stacknode(lhs))
@@ -1150,6 +1153,10 @@ static Node *compare(Simp *s, Node *n, int fields)
Node *r;
Op newop;
+ /* void is always void */
+ if (tybase(exprtype(n->expr.args[0]))->type == Tyvoid)
+ return mkboollit(n->loc, 1);
+
newop = Obad;
if (istysigned(tybase(exprtype(n->expr.args[0]))))
newop = cmpmap[n->expr.op][0];
@@ -1509,7 +1516,7 @@ static Node *rval(Simp *s, Node *n, Node *dst)
break;
case Ovar:
r = loadvar(s, n, dst);
- break;
+ break;;
case Oidxlen:
if (s->nidxctx == 0)
fatal(n, "'$' undefined outside of index or slice expression");
@@ -1540,12 +1547,7 @@ static Node *rval(Simp *s, Node *n, Node *dst)
append(s, mkexpr(n->loc, Oret, NULL));
break;
case Oasn:
- if (tybase(exprtype(n))->type == Tyvoid) {
- if (!ispure(args[1]))
- r = rval(s, args[1], NULL);
- } else {
- r = assign(s, args[0], args[1]);
- }
+ r = assign(s, args[0], args[1]);
break;
case Ocall:
r = simpcall(s, n, dst);