summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-14 23:27:06 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-14 23:27:06 -0800
commitf5a1454387098fa3abb7bf95f4123e1fac85cb7d (patch)
treec5410430516ebf119d8139c8b599732cbd545d51 /6
parent607b2662bc1093833bfea0c49236f098271cf348 (diff)
downloadmc-f5a1454387098fa3abb7bf95f4123e1fac85cb7d.tar.gz
Initial support for void as an expression.
Diffstat (limited to '6')
-rw-r--r--6/blob.c1
-rw-r--r--6/isel.c1
-rw-r--r--6/simp.c10
3 files changed, 10 insertions, 2 deletions
diff --git a/6/blob.c b/6/blob.c
index a215e93..0be2af2 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -134,6 +134,7 @@ static size_t bloblit(Blob *seq, Htab *strtab, Node *v, Type *ty)
assert(v->type == Nlit);
sz = tysize(ty);
switch (v->lit.littype) {
+ case Lvoid: break;
case Lint: b(seq, mkblobi(intsz[sz], v->lit.intval)); break;
case Lbool: b(seq, mkblobi(Bti8, v->lit.boolval)); break;
case Lchr: b(seq, mkblobi(Bti32, v->lit.chrval)); break;
diff --git a/6/isel.c b/6/isel.c
index 356bdca..c9de7e1 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -133,6 +133,7 @@ static Loc *loc(Isel *s, Node *n)
case Olit:
v = n->expr.args[0];
switch (v->lit.littype) {
+ case Lvoid: l = NULL; break;
case Lchr: l = loclit(v->lit.chrval, mode(n)); break;
case Lbool: l = loclit(v->lit.boolval, mode(n)); break;
case Lint: l = loclit(v->lit.intval, mode(n)); break;
diff --git a/6/simp.c b/6/simp.c
index 03ad0b1..1f2aee3 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1328,6 +1328,8 @@ static Node *simpcall(Simp *s, Node *n, Node *dst)
for (i = 1; i < n->expr.nargs; i++) {
if (i < ft->nsub && tybase(ft->sub[i])->type == Tyvalist)
lappend(&args, &nargs, vatypeinfo(s, n));
+ if (tybase(exprtype(n->expr.args[i]))->type == Tyvoid)
+ continue;
lappend(&args, &nargs, rval(s, n->expr.args[i], NULL));
if (exprop(n->expr.args[i]) == Oaddr)
if (exprop(n->expr.args[i]->expr.args[0]) == Ovar)
@@ -1483,7 +1485,10 @@ static Node *rval(Simp *s, Node *n, Node *dst)
break;
case Olit:
switch (args[0]->lit.littype) {
- case Lchr: case Lbool: case Llbl:
+ case Lvoid:
+ case Lchr:
+ case Lbool:
+ case Llbl:
r = n;
break;
case Lint:
@@ -1535,7 +1540,8 @@ static Node *rval(Simp *s, Node *n, Node *dst)
append(s, mkexpr(n->loc, Oret, NULL));
break;
case Oasn:
- r = assign(s, args[0], args[1]);
+ if (tybase(exprtype(n))->type != Tyvoid)
+ r = assign(s, args[0], args[1]);
break;
case Ocall:
r = simpcall(s, n, dst);