[hackers] [scc] [cc2] Fix commit de755db || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 22 Sep 2016 09:39:20 +0200 (CEST)

commit 22f9af5cb85c1e7cb2e3fd78fd4162b8d0b841ca
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 20 14:17:27 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_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
_AT_@ -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
_AT_@ -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
_AT_@ -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
_AT_@ -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
_AT_@ -12,6 +12,7 @@ enum tflags {
         AGGRF = 16,
         FUNF = 32,
         PARF = 64,
+ INITF = 128
 };
 
 enum sclass {
_AT_@ -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
_AT_@ -572,7 +572,7 @@ vardecl(void)
         sym->kind = sclass;
 
         if (ininit)
- sym->kind = INITF;
+ sym->type.flags |= INITF;
         decl(sym);
         delnode(np);
 }
Received on Thu Sep 22 2016 - 09:39:20 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 22 2016 - 09:48:15 CEST