commit fbd7247cc8cf0a6829d6a9a1e7e9f26f30e4005d
parent ea7eeb566e8f2493e3495d974ba587ffabbe027d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 19 Jan 2016 15:38:53 +0100
Convert empry inirializers to the correct type
zero has integer type, and it is not what we always want.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/cc1/code.c b/cc1/code.c
@@ -328,9 +328,10 @@ emitdesig(Node *np, Type *tp)
case PTR:
case INT:
case ENUM:
- aux = (sym) ? *sym->u.init : constnode(zero);
+ aux = (sym) ? *sym->u.init : convert(constnode(zero), tp, 0);
emitexp(OEXPR, aux);
break;
+ /* TODO: case UNION: */
case STRUCT:
case ARY:
for (n = 0; n < tp->n.elem; ++n) {
@@ -339,10 +340,13 @@ emitdesig(Node *np, Type *tp)
}
break;
default:
- /* TODO: Handle other kind of constants */
abort();
}
+ if (sym) {
+ free(sym->u.init);
+ sym->u.init = NULL;
+ }
freetree(np);
return;