ref: d13e4fe2e99ade7fffe53f72519ded2c1fb3665b
parent: 6951768c2d14176b68ab6b514ff2b0684df6d045
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Sep 16 10:23:11 EDT 2016
[cc2] Move INITF to sclass If the symbol is a initializer is something that is not related to the type of the symbol, so the best place for it is in the storage class, which is a property of the symbol, not of the type.
--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
@@ -139,13 +139,13 @@
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
Type *tp = &sym->type;
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
@@ -138,13 +138,13 @@
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
Type *tp = &sym->type;
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -271,7 +271,7 @@
if (sym->kind == SGLOB)
fputs("export ", stdout);
printf("data %s = {\n", symname(sym));
- if (sym->type.flags & INITF)
+ if (sym->kind == INITF)
return;
printf("\tz\t%lu\n}\n", sym->type.size);
}
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -55,12 +55,12 @@
static void
label(Symbol *sym)
{
- int seg, flags = sym->type.flags;
+ int seg;
char *name = symname(sym);
- if (flags & FUNF)
+ if (sym->type.flags & FUNF)
seg = CODESEG;
- else if (flags & INITF)
+ else if (sym->kind == INITF)
seg = DATASEG;
else
seg = BSSSEG;
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -12,7 +12,6 @@
UNIONF = 16,
FUNF = 32,
PARF = 64,
- INITF = 128
};
enum sclass {
@@ -28,6 +27,7 @@
SMEMB = 'M',
SCONST = '#',
STRING = '"',
+ INITF = '=',
SNONE = 0 /* cc2 relies on SNONE being 0 in nextpc() */
};
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -571,7 +571,7 @@
sym->kind = sclass;
if (ininit)
- sym->type.flags |= INITF;
+ sym->kind = INITF;
decl(sym);
delnode(np);
}