scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 15240d34f2bc772e6232385437fa80dd424dac80
parent 1aa2143073c30f374c33e0288135dc3e04494588
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 25 Nov 2015 22:33:08 +0100

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).

Diffstat:
Mcc1/expr.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -1186,7 +1186,7 @@ initializer(Symbol *sym, Type *tp, int nelem) 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 @@ initializer(Symbol *sym, Type *tp, int nelem) } else { np->op = OASSIGN; emit(OEXPR, np); - } + } }