From 045ddffae08419e2df9f40b878ecd58e705275e1 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 5 Apr 2020 15:35:28 -0700 Subject: expr: Just ignore decayed operand in unary `&` operator Reusing the decayed expression is more complicated, and only saved one malloc. --- expr.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/expr.c b/expr.c index 7d13b44..8b10bf4 100644 --- a/expr.c +++ b/expr.c @@ -119,14 +119,9 @@ mkunaryexpr(enum tokenkind op, struct expr *base) switch (op) { case TBAND: if (base->decayed) { - /* - An array gets decayed to a pointer to its first element, - but with an explicit '&' operator, it is a pointer to - the array. - */ - base->type = mkpointertype(base->base->type, base->base->qual); - base->decayed = false; - return base; + expr = base; + base = base->base; + free(expr); } /* Allow struct and union types even if they are not lvalues, -- cgit v1.2.3