shithub: scc

Download patch

ref: 7384036a2738f3f975eeebec10156eaea478e386
parent: b7f42e58b25d64fa8a03e8ac06a5f5e5e92c552a
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 20 10:17:27 EDT 2016

[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.

--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
@@ -145,7 +145,7 @@
 
 	if (sym->type.flags & FUNF)
 		seg = CODESEG;
-	else if (sym->kind == INITF)
+	else if (sym->type.flags & INITF)
 		seg = DATASEG;
 	else
 		seg = BSSSEG;
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
@@ -144,7 +144,7 @@
 
 	if (sym->type.flags & FUNF)
 		seg = CODESEG;
-	else if (sym->kind == INITF)
+	else if (sym->type.flags & INITF)
 		seg = DATASEG;
 	else
 		seg = BSSSEG;
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -274,7 +274,7 @@
 	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);
 }
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -60,7 +60,7 @@
 
 	if (sym->type.flags & FUNF)
 		seg = CODESEG;
-	else if (sym->kind == INITF)
+	else if (sym->type.flags & INITF)
 		seg = DATASEG;
 	else
 		seg = BSSSEG;
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -12,6 +12,7 @@
 	AGGRF   =    16,
 	FUNF    =    32,
 	PARF    =    64,
+	INITF   =   128
 };
 
 enum sclass {
@@ -27,7 +28,6 @@
 	SMEMB     = 'M',
 	SCONST    = '#',
 	STRING    = '"',
-	INITF   =   '=',
 	SNONE     = 0 /* cc2 relies on SNONE being 0 in nextpc() */
 };
 
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -572,7 +572,7 @@
 	sym->kind = sclass;
 
 	if (ininit)
-		sym->kind = INITF;
+		sym->type.flags |= INITF;
 	decl(sym);
 	delnode(np);
 }