[hackers] [scc] Support empty compound initializers || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 17 Jan 2016 21:57:55 +0100 (CET)

commit c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sun Jan 17 21:46:49 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_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
_AT_@ -16,6 +16,7 @@ struct designator {
 
 struct inititlizer {
         Type *type;
+ TUINT curpos;
         struct designator *head;
 };
 
_AT_@ -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:
Received on Sun Jan 17 2016 - 21:57:55 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 17 2016 - 22:00:29 CET