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 5f75e0b752978450bac1fd82b977727bebce52f3
parent 8f8fd768089ae3ac82fd421b1ebd1a80f9fca5fc
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 10 Apr 2019 23:40:36 -0700

expr: Pointer arithmetic requires complete *object* types

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

diff --git a/expr.c b/expr.c @@ -159,7 +159,7 @@ mkbinaryexpr(struct location *loc, enum tokenkind op, struct expr *l, struct exp if (l->type->kind != TYPEPOINTER || !(rp & PROPINT)) error(loc, "invalid operands to '+' operator"); t = l->type; - if (t->base->incomplete) + if (t->base->incomplete || !(typeprop(t->base) & PROPOBJECT)) error(loc, "pointer operand to '+' must be to complete object type"); r = mkbinaryexpr(loc, TMUL, exprconvert(r, &typeulong), mkconstexpr(&typeulong, t->base->size)); break; @@ -170,7 +170,7 @@ mkbinaryexpr(struct location *loc, enum tokenkind op, struct expr *l, struct exp } if (l->type->kind != TYPEPOINTER || !(rp & PROPINT) && r->type->kind != TYPEPOINTER) error(loc, "invalid operands to '-' operator"); - if (l->type->base->incomplete) + if (l->type->base->incomplete || !(typeprop(l->type->base) & PROPOBJECT)) error(loc, "pointer operand to '-' must be to complete object type"); if (rp & PROPINT) { t = l->type;