diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 33e854bc1..528ff7801 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1863,8 +1863,24 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t) switch (e1->type) { case ex_symbol: if (e1->e.symbol->sy_type == sy_var) { - e = new_unary_expr ('&', e1); - e->e.expr.type = pointer_type (t); + def_t *def = e1->e.symbol->s.def; + type_t *type = def->type; + + if (is_struct (type) || is_class (type)) { + e = new_pointer_expr (0, t, def); + e->line = e1->line; + e->file = e1->file; + } else if (is_array (type)) { + e = e1; + e->type = ex_value; + e->e.value.type = ev_pointer; + e->e.value.v.pointer.val = 0; + e->e.value.v.pointer.type = t; + e->e.value.v.pointer.def = def; + } else { + e = new_unary_expr ('&', e1); + e->e.expr.type = pointer_type (t); + } break; } return error (e1, "invalid type for unary &");