From 0bb7273d42117585aeeda4610267158fcea494a6 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 4 Apr 2020 19:10:47 -0700 Subject: expr: Fix type of '&' operator applied to array It should be a pointer to the array, not to the first element (as it would after implicit conversion without the '&' operator). --- expr.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'expr.c') diff --git a/expr.c b/expr.c index 4762d7a..2508879 100644 --- a/expr.c +++ b/expr.c @@ -119,6 +119,12 @@ 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; } -- cgit v1.2.3