summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-02-01 22:20:38 -0800
committerOri Bernstein <ori@eigenstate.org>2016-02-01 22:20:38 -0800
commit323f7cc44629fbac0375236b37c7673434eddb69 (patch)
treebb6db326a719558e30a93b331e36d37875f4c3dc /6/simp.c
parent74d50fbf7247fb39c27c673f789c781174d0d653 (diff)
downloadmc-323f7cc44629fbac0375236b37c7673434eddb69.tar.gz
Fix type array typedef indexing.
We weren't looking at the base appropriately.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/6/simp.c b/6/simp.c
index 4b7af73..b1fe969 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -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);