commit 15240d34f2bc772e6232385437fa80dd424dac80
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Wed Nov 25 22:33:08 2015 +0100
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Wed Nov 25 22:33:08 2015 +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).

diff --git a/cc1/expr.c b/cc1/expr.c
index 124dc31..d28ebd1 100644
--- 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);
-       }       
+       }
 }

Reply via email to