shithub: scc

Download patch

ref: 1ad229b4a8dc58eddc4b4880dd470e093d6d4433
parent: b8d8981da6ab2fd80153db23d30ca36c6d8250fb
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 1 19:25:17 EDT 2021

cc1: Allocate an identifier for local initializers

In the case of local initializers a hidden variable is emitted,
but this variable lacked an identifer. In this case, the default
identifier is 0, that cc2 understand as a temporary value, which
meant that it was not inserted in the hash table. Every access
to the symbol identified by 0 was generating new symbols, without
relation between them.

--- a/src/cmd/cc/cc1/init.c
+++ b/src/cmd/cc/cc1/init.c
@@ -327,6 +327,7 @@
 		if (!(np->flags & NCONST))
 			abort(); /* TODO */
 		hidden = newsym(NS_IDEN, NULL);
+		hidden->id = newid();
 		hidden->type = sym->type;
 		hidden->flags |= SLOCAL | SHASINIT;
 		emit(ODECL, hidden);