shithub: scc

Download patch

ref: c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6
parent: 5d74dc264ed9a012ad74016ed02b2cd9d96d75b1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 17 16:46:49 EST 2016

Support empty compound initializers

--- a/cc1/init.c
+++ b/cc1/init.c
@@ -16,6 +16,7 @@
 
 struct inititlizer {
 	Type *type;
+	TUINT curpos;
 	struct designator *head;
 };
 
@@ -91,8 +92,12 @@
 	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: