shithub: scc

Download patch

ref: 3939d91c2494e9de10f4f7e8a692544416c5f021
parent: 71c6d0ec20a1644b4cf34d52691993d271417660
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 8 18:36:19 EDT 2015

Fix grammar of aggregate initializers

After last commits, the grammar was incorrect because
there was no loop until no accept(,').

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -363,11 +363,15 @@
 static void
 initializer(Symbol *sym)
 {
-	Type *tp = sym->type;
 	Node *np;
 
 	if (accept('{')) {
-		initializer(sym);
+		do {
+			if (yytoken == '}')
+				break;
+			initializer(sym);
+		} while (accept(',');
+
 		expect('}');
 		return;
 	}
@@ -376,7 +380,6 @@
 		emit(OEXPR, assignop(OINIT, varnode(sym), np));
 		return;
 	}
-	return;
 }
 
 static Symbol *