aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--expr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/expr.c b/expr.c
index 683d117..70d8dbf 100644
--- a/expr.c
+++ b/expr.c
@@ -378,6 +378,8 @@ postfixexpr(struct scope *s, struct expression *r)
next();
arr = r;
idx = expr(s);
+ lvalueconvert(arr);
+ lvalueconvert(idx);
if (arr->type->kind != TYPEPOINTER) {
if (idx->type->kind != TYPEPOINTER)
error(&tok.loc, "either array or index must be pointer type");
@@ -387,7 +389,6 @@ postfixexpr(struct scope *s, struct expression *r)
}
if (arr->type->base->incomplete)
error(&tok.loc, "array is pointer to incomplete type");
- lvalueconvert(idx);
if (!(typeprop(idx->type) & PROPINT))
error(&tok.loc, "index is not an integer type");
tmp = mkbinaryexpr(&tok.loc, TADD, arr, idx);