scc

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

commit 22f9af5cb85c1e7cb2e3fd78fd4162b8d0b841ca
parent 52958e5bbdf55f88a0abaab3b2cb130ba148710a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 20 Sep 2016 14:17:27 +0200

[cc2] Fix commit de755db

This commit broke initializers, because it was using the storage class of
the symbol to store the flag that the symbol have an initializers, destroying
the storage class of the symbol. This commit revert that patch and put a
similar situation.

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

diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c @@ -145,7 +145,7 @@ label(Symbol *sym) if (sym->type.flags & FUNF) seg = CODESEG; - else if (sym->kind == INITF) + else if (sym->type.flags & INITF) seg = DATASEG; else seg = BSSSEG; diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c @@ -144,7 +144,7 @@ label(Symbol *sym) if (sym->type.flags & FUNF) seg = CODESEG; - else if (sym->kind == INITF) + else if (sym->type.flags & INITF) seg = DATASEG; else seg = BSSSEG; diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -274,7 +274,7 @@ defglobal(Symbol *sym) if (sym->kind == SGLOB) fputs("export ", stdout); printf("data %s = {\n", symname(sym)); - if (sym->kind == INITF) + if (sym->type.flags & INITF) return; printf("\tz\t%lu\n}\n", sym->type.size); } diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c @@ -60,7 +60,7 @@ label(Symbol *sym) if (sym->type.flags & FUNF) seg = CODESEG; - else if (sym->kind == INITF) + else if (sym->type.flags & INITF) seg = DATASEG; else seg = BSSSEG; diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -12,6 +12,7 @@ enum tflags { AGGRF = 16, FUNF = 32, PARF = 64, + INITF = 128 }; enum sclass { @@ -27,7 +28,6 @@ enum sclass { SMEMB = 'M', SCONST = '#', STRING = '"', - INITF = '=', SNONE = 0 /* cc2 relies on SNONE being 0 in nextpc() */ }; diff --git a/cc2/parser.c b/cc2/parser.c @@ -572,7 +572,7 @@ vardecl(void) sym->kind = sclass; if (ininit) - sym->kind = INITF; + sym->type.flags |= INITF; decl(sym); delnode(np); }