shithub: scc

Download patch

ref: b79fb78e5800e18978ed22288e8ad3bf6702cf0d
parent: 79412493b4cd9c428b6335613d9f720b79b3faf8
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Jan 20 10:52:01 EST 2016

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.

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -313,6 +313,7 @@
 	Symbol *sym;
 	size_t n;
 	Node *aux;
+	Type *p;
 
 	if (!np) {
 		sym = NULL;
@@ -336,7 +337,8 @@
 	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: