diff options
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -121,6 +121,7 @@ static struct expr * mkunaryexpr(enum tokenkind op, struct expr *base) { struct expr *expr; + struct type *type; switch (op) { case TBAND: @@ -143,10 +144,16 @@ mkunaryexpr(enum tokenkind op, struct expr *base) case TMUL: if (base->type->kind != TYPEPOINTER) error(&tok.loc, "cannot dereference non-pointer"); - expr = mkexpr(EXPRUNARY, base->type->base, base); - expr->qual = base->type->qual; - expr->lvalue = true; - expr->op = op; + if (base->kind == EXPRUNARY && base->op == TBAND) { + type = base->type->base; + expr = base->base; + expr->type = type; + } else { + expr = mkexpr(EXPRUNARY, base->type->base, base); + expr->qual = base->type->qual; + expr->lvalue = true; + expr->op = op; + } return decay(expr); } /* other unary operators get compiled as equivalent binary ones */ |