[hackers] [scc] [cc2] Allocate space for symbols always || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 4 Apr 2016 09:40:36 +0200 (CEST)

commit 4a4f4ec1004bd0ccc457377724a596976dcc0df8
Author: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
AuthorDate: Mon Apr 4 09:24:47 2016 +0200
Commit: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
CommitDate: Mon Apr 4 09:24:47 2016 +0200

    [cc2] Allocate space for symbols always
    
    The current code was passing 1 in alloc parameter of defsym()
    only when there was not an initializer, but this semantic
    was wrong and it creates problems with qbe. The correct
    semantic is to pass 1 and let to the function to determine
    what it has to do based in the information of the symbol.

diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c
index 9d3ce60..3d46270 100644
--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
_AT_@ -177,7 +177,7 @@ void
 defsym(Symbol *sym, int alloc)
 {
         label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
                 return;
         size2asm(&sym->type);
         puts("0");
diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c
index d032c1b..4e75be2 100644
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
_AT_@ -176,7 +176,7 @@ void
 defsym(Symbol *sym, int alloc)
 {
         label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
                 return;
         size2asm(&sym->type);
         puts("0");
diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c
index e2223af..7a3604f 100644
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
_AT_@ -165,7 +165,7 @@ void
 defsym(Symbol *sym, int alloc)
 {
         label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
                 return;
         size2asm(&sym->type);
         puts("0");
diff --git a/cc2/parser.c b/cc2/parser.c
index 2f71a20..43e1dc3 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -512,7 +512,7 @@ decl(Symbol *sym)
                 case GLOB:
                 case PRIVAT:
                 case LOCAL:
- alloc = (tp->flags & INITF) == 0;
+ alloc = 1;
                         break;
                 case AUTO:
                 case REG:
Received on Mon Apr 04 2016 - 09:40:36 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 04 2016 - 09:48:17 CEST