cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 13fb267e24dd0fbe011d29dc6d3b2512c66118b6
parent e22b4bd48c85de1c5f62a4ccbf178668b02f191d
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 13 Feb 2019 12:11:13 -0800

expr: Perform lvalue conversion on array and index in subscript expressions

Diffstat:
Mexpr.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 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);