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 045ddffae08419e2df9f40b878ecd58e705275e1
parent 87cf5431f3ed9ed5fa4a8b99cd5b9582ebff23ae
Author: Michael Forney <mforney@mforney.org>
Date:   Sun,  5 Apr 2020 15:35:28 -0700

expr: Just ignore decayed operand in unary `&` operator

Reusing the decayed expression is more complicated, and only saved
one malloc.

Diffstat:
Mexpr.c | 11+++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git 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,