ref: 537a655de72c1d487584e9c65c8ba53c00ae1f6b
parent: 95af25e88783f47b532bf9cd1803426ac422bb19
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Apr 4 05:24:47 EDT 2016
[cc2] Allocate space for symbols always The current code was passing 1 in alloc parameter of defsym() only when there was not an initializer, but this semantic was wrong and it creates problems with qbe. The correct semantic is to pass 1 and let to the function to determine what it has to do based in the information of the symbol.
--- a/cc2/arch/amd64-sysv/code.c
+++ b/cc2/arch/amd64-sysv/code.c
@@ -177,7 +177,7 @@
defsym(Symbol *sym, int alloc)
{
label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
return;
size2asm(&sym->type);
puts("0");
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
@@ -176,7 +176,7 @@
defsym(Symbol *sym, int alloc)
{
label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
return;
size2asm(&sym->type);
puts("0");
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -165,7 +165,7 @@
defsym(Symbol *sym, int alloc)
{
label(sym);
- if (!alloc)
+ if (!alloc || (sym->type.flags & INITF))
return;
size2asm(&sym->type);
puts("0");
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -512,7 +512,7 @@
case GLOB:
case PRIVAT:
case LOCAL:
- alloc = (tp->flags & INITF) == 0;
+ alloc = 1;
break;
case AUTO:
case REG:
--
⑨