From 008359862b0bb4ab6bf68ab402e8eb6472f56bae Mon Sep 17 00:00:00 2001 From: Bill Currie <bill@taniwha.org> Date: Thu, 3 Feb 2022 14:35:43 +0900 Subject: [PATCH] [qfcc] Avoid pointer alias of address expressions Since address expressions always product a pointer type, aliasing one to another pointer type is redundant. Instead, simply return an address expression with the desired type. --- tools/qfcc/source/expr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 7b1d76372..341f6d7a9 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1346,6 +1346,12 @@ is_pointer_val (expr_t *e) expr_t * new_alias_expr (type_t *type, expr_t *expr) { + if (is_ptr (type) && expr->type == ex_address) { + // avoid aliasing a pointer to a pointer (redundant) + expr = copy_expr (expr); + expr->e.address.type = type; + return expr; + } if (expr->type == ex_alias) { if (expr->e.alias.offset) { return new_offset_alias_expr (type, expr, 0);