summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-27 22:15:41 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-27 22:15:41 -0800
commit37bfca6f1d5043a969104037a0dfc4f8956e7c77 (patch)
tree2d4c7ef04021a3f2a33c148fc998b373946a4ad5 /6/simp.c
parent4c23b2a4324da13e2f6027a4f53107a46568373b (diff)
downloadmc-37bfca6f1d5043a969104037a0dfc4f8956e7c77.tar.gz
Make literal empty slices in blobs zero.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/6/simp.c b/6/simp.c
index b433d49..12e1cf5 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1937,12 +1937,18 @@ static Func *simpfn(Simp *s, char *name, Node *dcl)
static void extractsub(Simp *s, Node *e)
{
size_t i;
+ Node *sub;
assert(e != NULL);
switch (exprop(e)) {
case Oslice:
- if (exprop(e->expr.args[0]) == Oarr)
+ sub = e->expr.args[0];
+ if (exprop(sub) == Oarr && sub->expr.nargs > 0) {
e->expr.args[0] = simpblob(s, e->expr.args[0]);
+ } else {
+ e->expr.args[0] = mkintlit(e->loc, 0);
+ e->expr.args[0]->expr.type = tyintptr;
+ }
break;
case Oarr:
case Ostruct: