commit c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6 parent 5d74dc264ed9a012ad74016ed02b2cd9d96d75b1 Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Sun, 17 Jan 2016 21:46:49 +0100 Support empty compound initializers Diffstat:
M | cc1/init.c | | | 9 | +++++++-- |
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/cc1/init.c b/cc1/init.c @@ -16,6 +16,7 @@ struct designator { struct inititlizer { Type *type; + TUINT curpos; struct designator *head; }; @@ -91,8 +92,12 @@ initlist(Symbol *sym, Type *tp) TINT n; Type *newtp; - /* TODO: catch the case of empty list */ - for (n = 0; ; ++n) { + ip = xmalloc(sizeof(*ip)); + ip->head = NULL; + if (accept('}')) + return NULL; + + for (ip->curpos = 0; ; ++ip->curpos) { designation(ip); switch (tp->op) { case ARY: