diff options
author | Michael Forney <mforney@mforney.org> | 2020-04-04 19:10:47 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-04-04 19:10:47 -0700 |
commit | 0bb7273d42117585aeeda4610267158fcea494a6 (patch) | |
tree | 096d2b3c4afec138b471664441134347e42a08d5 /expr.c | |
parent | ea8f0ebd571931c37aadeab0c2c57b271dee0e41 (diff) |
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).
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; } |