shithub: scc

Download patch

ref: 3eb074604d8c04734b97de4ef489f2a94431c5a8
parent: e6ef99231498cfcd683a5132b7de6f266e50444d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 19 02:27:19 EST 2016

Allow declaration of arrays without size

Such arrays have incomplete type, but if they are initialized
them the type is completed with the information taken from the
initializer.

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -728,8 +728,11 @@
 		return sym;
 
 	/* TODO: Add warning about ANSI limits */
-	if (!tp->defined && sclass != EXTERN && sclass != TYPEDEF)
+	if (!tp->defined                          &&
+	    sclass != EXTERN && sclass != TYPEDEF &&
+	    !(tp->op == ARY && yytoken == '=')) {
 		errorp("declared variable '%s' of incomplete type", name);
+	}
 
 	if (tp->op != FTN) {
 		sym = install(NS_IDEN, sym);