diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-02-01 22:20:38 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-02-01 22:20:38 -0800 |
commit | 323f7cc44629fbac0375236b37c7673434eddb69 (patch) | |
tree | bb6db326a719558e30a93b331e36d37875f4c3dc /6 | |
parent | 74d50fbf7247fb39c27c673f789c781174d0d653 (diff) | |
download | mc-323f7cc44629fbac0375236b37c7673434eddb69.tar.gz |
Fix type array typedef indexing.
We weren't looking at the base appropriately.
Diffstat (limited to '6')
-rw-r--r-- | 6/simp.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -723,21 +723,22 @@ static Node *idxaddr(Simp *s, Node *seq, Node *idx) { Node *a, *t, *u, *v, *w; /* temps */ Node *r; /* result */ - Type *ty; + Type *ty, *seqty; size_t sz; a = rval(s, seq, NULL); - ty = exprtype(seq)->sub[0]; - if (exprtype(seq)->type == Tyarray) { + seqty = tybase(exprtype(seq)); + ty = seqty->sub[0]; + if (seqty->type == Tyarray) { t = addr(s, a, ty); - w = exprtype(a)->asize; - } else if (seq->expr.type->type == Tyslice) { + w = seqty->asize; + } else if (seqty->type == Tyslice) { t = load(addr(s, a, mktyptr(seq->loc, ty))); w = slicelen(s, a); } else { - die("Can't index type %s\n", tystr(seq->expr.type)); + die("can't index type %s", tystr(seq->expr.type)); } - assert(t->expr.type->type == Typtr); + assert(exprtype(t)->type == Typtr); u = rval(s, idx, NULL); u = ptrsized(s, u); checkidx(s, Olt, w, u); |