commit 22f9af5cb85c1e7cb2e3fd78fd4162b8d0b841ca
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Tue Sep 20 14:17:27 2016 +0200
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Tue Sep 20 14:17:27 2016 +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.

diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c
index 7aa4081..cc006f5 100644
--- 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
index fdf5d63..5df3428 100644
--- 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
index 677c5d6..bd5fd3d 100644
--- 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
index d3f70be..d2bb06e 100644
--- 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
index c5256cb..dbf078e 100644
--- 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
index dfa6f1e..e7f0112 100644
--- 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);
 }

Reply via email to