scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit b79fb78e5800e18978ed22288e8ad3bf6702cf0d
parent 79412493b4cd9c428b6335613d9f720b79b3faf8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 20 Jan 2016 15:52:01 +0100

Select the correct type in emitdesig()

The child type in arrays is the subtype, but in struct/unions is
the type in the array of fields of the type.

Diffstat:
Mcc1/code.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -313,6 +313,7 @@ emitdesig(Node *np, Type *tp) Symbol *sym; size_t n; Node *aux; + Type *p; if (!np) { sym = NULL; @@ -336,7 +337,8 @@ emitdesig(Node *np, Type *tp) case ARY: for (n = 0; n < tp->n.elem; ++n) { aux = (sym) ? sym->u.init[n] : NULL; - emitdesig(aux, tp->type); + p = (tp->op == ARY) ? tp->type : tp->p.fields[n]->type; + emitdesig(aux, p); } break; default: