[hackers] [scc] Select the correct type in emitdesig() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 20 Jan 2016 16:02:23 +0100 (CET)

commit b79fb78e5800e18978ed22288e8ad3bf6702cf0d
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Jan 20 15:52:01 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Jan 20 15:52:01 2016 +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.

diff --git a/cc1/code.c b/cc1/code.c
index 8051282..ef33cb0 100644
--- a/cc1/code.c
+++ b/cc1/code.c
_AT_@ -313,6 +313,7 @@ emitdesig(Node *np, Type *tp)
         Symbol *sym;
         size_t n;
         Node *aux;
+ Type *p;
 
         if (!np) {
                 sym = NULL;
_AT_@ -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:
Received on Wed Jan 20 2016 - 16:02:23 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 20 2016 - 16:12:27 CET