shithub: scc

Download patch

ref: 15240d34f2bc772e6232385437fa80dd424dac80
parent: 1aa2143073c30f374c33e0288135dc3e04494588
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Nov 25 17:33:08 EST 2015

Fix static initializers

Static initializers can be only initialized by
constant expressions, and the static types we
have are GLOBAL, LOCAL and PRIVATE (static
with global context, function context and
file context).

--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -1186,7 +1186,7 @@
 
 	np = assignop(OINIT, varnode(sym), np);
 
-	if ((flags & (ISEXTERN|ISTYPEDEF)) != 0) {
+	if ((flags & (ISGLOBAL|ISLOCAL|ISPRIVATE)) != 0) {
 		if (!np->right->constant)
 			errorp("initializer element is not constant");
 		emit(OINIT, np);
@@ -1196,5 +1196,5 @@
 	} else {
 		np->op = OASSIGN;
 		emit(OEXPR, np);
-	}	
+	}
 }