From 554f4d071a9016b2f30aef281d5304ab6a0e1515 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 13 Nov 2004 13:22:30 +0000 Subject: [PATCH] get the type right when accessing arrays in a struct (in a pointer?) This is an imperfect revision of history. --- tools/qfcc/source/expr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index bc75324af..d096a9c3c 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -2278,6 +2278,7 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t) return e2; if (e->type == ex_pointer && e2->type == ex_short) { e->e.pointer.val += e2->e.short_val; + e->e.pointer.type = t; } else { if (e2->type != ex_short || e2->e.short_val) { if (e->type == ex_expr && e->e.expr.op == '&') { @@ -2358,14 +2359,19 @@ assign_expr (expr_t *e1, expr_t *e2) else return error (e1, "invalid lvalue in assignment"); } - //XXX func = func ??? - check_initialized (e2); t1 = get_type (e1); t2 = get_type (e2); if (!t1 || !t2) { error (e1, "internal error"); abort (); } + //XXX func = func ??? + if (t1->type != ev_pointer || t2->type != ev_array) + check_initialized (e2); + else { + e2 = address_expr (e2, 0, t2->aux_type); + t2 = get_type (e2); + } if (e2->type == ex_bool) e2 = convert_from_bool (e2, t1);