diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-13 12:11:13 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-13 12:11:13 -0800 |
commit | 13fb267e24dd0fbe011d29dc6d3b2512c66118b6 (patch) | |
tree | e6073624da17fd837c97bf43aa30f179db66d864 | |
parent | e22b4bd48c85de1c5f62a4ccbf178668b02f191d (diff) |
expr: Perform lvalue conversion on array and index in subscript expressions
-rw-r--r-- | expr.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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); |