shithub: scc

Download patch

ref: 2ba16ff549dccdaf9a6c915f3f9219410b9d5e3e
parent: db5082d4c59b6350e7ab271dd751c40fddc68eb9
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jul 13 14:35:20 EDT 2017

[cc1] Allow non constant initializers in scalar vars

They aren't a problem, aggregate variables are the problem

--- a/cc1/init.c
+++ b/cc1/init.c
@@ -296,12 +296,12 @@
 	Type *tp = sym->type;
 	size_t n; /* FIXME: It should be SIZET */
 
-	if (!(np->flags & NCONST))
-		abort(); /* TODO: Implement not constant initializers */
 
 repeat:
 	switch (tp->op) {
 	case UNION:
+		if (!(np->flags & NCONST))
+			abort(); /* TODO */
 		n = tp->n.elem-1;
 		tp = tp->p.fields[n]->type;
 		np = np->sym->u.init[n];
@@ -308,6 +308,8 @@
 		goto repeat;
 	case ARY:
 	case STRUCT:
+		if (!(np->flags & NCONST))
+			abort(); /* TODO */
 		hidden = newsym(NS_IDEN, NULL);
 		hidden->type = sym->type;
 		hidden->flags |= SLOCAL | SHASINIT;