aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-04-05 15:35:28 -0700
committerMichael Forney <mforney@mforney.org>2020-04-05 15:35:28 -0700
commit045ddffae08419e2df9f40b878ecd58e705275e1 (patch)
treee5a9c96980ed10bb70ca86236794c5d0c186f218
parent87cf5431f3ed9ed5fa4a8b99cd5b9582ebff23ae (diff)
downloadcproc-045ddffae08419e2df9f40b878ecd58e705275e1.tar.xz
expr: Just ignore decayed operand in unary `&` operator
Reusing the decayed expression is more complicated, and only saved one malloc.
-rw-r--r--expr.c11
1 files 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,