[hackers] [scc] Do not emit decalrations until initializer || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 19 Jan 2016 10:55:47 +0100 (CET)

commit ee4660c4b1081fbe4d5ae68a68132f9e1b629a5c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jan 19 10:49:29 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jan 19 10:49:29 2016 +0100

    Do not emit decalrations until initializer
    
    Incomplete array types are converted to complete when they
    have a initializer, but incomplete types are not emited, so
    it is impossible for the backend to know what is the size of
    the initializer.

diff --git a/cc1/decl.c b/cc1/decl.c
index 3ce524b..eba7e3c 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -789,12 +789,12 @@ identifier(struct decl *dcl)
                 sym->flags = flags;
         }
 
- if (sym->token == IDEN && sym->type->op != FTN)
- emit(ODECL, sym);
         if (accept('='))
                 initializer(sym, sym->type);
         if (!(sym->flags & (ISGLOBAL|ISEXTERN)) && tp->op != FTN)
                 sym->flags |= ISDEFINED;
+ if (sym->token == IDEN && sym->type->op != FTN)
+ emit(ODECL, sym);
         return sym;
 }
 
diff --git a/cc1/init.c b/cc1/init.c
index b488620..93b4466 100644
--- a/cc1/init.c
+++ b/cc1/init.c
_AT_@ -244,6 +244,7 @@ initializer(Symbol *sym, Type *tp)
                 errorp("function '%s' is initialized like a variable", sym->name);
         np = initialize(tp);
 
+ emit(ODECL, sym);
         if (flags & ISDEFINED) {
                 errorp("redeclaration of '%s'", sym->name);
         } else if ((flags & (ISGLOBAL|ISLOCAL|ISPRIVATE)) != 0) {
Received on Tue Jan 19 2016 - 10:55:47 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 19 2016 - 11:00:31 CET