[hackers] [scc] Fix static initializers || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 25 Nov 2015 22:36:37 +0100 (CET)

commit 15240d34f2bc772e6232385437fa80dd424dac80
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Nov 25 22:33:08 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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);
_AT_@ -1196,5 +1196,5 @@ initializer(Symbol *sym, Type *tp, int nelem)
         } else {
                 np->op = OASSIGN;
                 emit(OEXPR, np);
- }
+ }
 }
Received on Wed Nov 25 2015 - 22:36:37 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 25 2015 - 22:48:11 CET