commit c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Sun Jan 17 21:46:49 2016 +0100
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Sun Jan 17 21:48:28 2016 +0100

    Support empty compound initializers

diff --git a/cc1/init.c b/cc1/init.c
index 668f830..8265ef2 100644
--- 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:

Reply via email to