scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit b4d7213017daf1c0b5f7732df3f9d02b45ee2037
parent 5679ed45adb286c3e17e5db68d5b4a2a64b23fcf
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Nov 2021 06:38:46 +0100

cc2/qbe: Use common symbols for tentative declarations

Common symbols allow multiple tentative definitions in
different symbols, which is a common extension of the C
language, specially in UNIX where C was born.

Diffstat:
Msrc/cmd/cc/cc2/target/qbe/code.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/cmd/cc/cc2/target/qbe/code.c b/src/cmd/cc/cc2/target/qbe/code.c @@ -287,10 +287,13 @@ defglobal(Symbol *sym) return; if (sym->kind == SGLOB) fputs("export ", stdout); - printf("data %s = align %d {\n", symname(sym), tp->align); - if (sym->type.flags & INITF) - return; - printf("\tz\t%lu\n}\n", tp->size); + + printf("data %s = %s align %d {\n", + symname(sym), + (tp->flags & INITF) ? "" : "common", + tp->align); + if ((tp->flags & INITF) == 0) + printf("\tz\t%lu\n}\n", tp->size); } void