mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[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.
This commit is contained in:
parent
80c6431544
commit
008359862b
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue