scc

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

commit 4a4f4ec1004bd0ccc457377724a596976dcc0df8
parent a965a5c6461e7db37ee552cb06834b8444728e67
Author: Roberto E. Vargas Caballero <roberto.vargas@igrid-td.com>
Date:   Mon,  4 Apr 2016 09:24:47 +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.

Diffstat:
Mcc2/arch/amd64-sysv/code.c | 2+-
Mcc2/arch/i386-sysv/code.c | 2+-
Mcc2/arch/z80/code.c | 2+-
Mcc2/parser.c | 2+-
4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c @@ -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 @@ -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 @@ -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 @@ -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: