shithub: scc

Download patch

ref: ed927690e4c089521410d92c9d3b06dbc33b95bd
parent: f73cc2f511c03315a6a4dfe6b8450b57b4fd1b49
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Mar 8 02:48:17 EST 2014

Initialize type pointer in struct symbols

Before this patch we were assign a new allocated type to the symbol,
and this new type had forward field to 0. The correct is not allocate a
new type and assign the input parameter as type of the symbol.

--- a/decl.c
+++ b/decl.c
@@ -66,12 +66,13 @@
 }
 
 /* TODO: Add the type to the symbol */
+
 static struct symbol *
 aggregate(register struct ctype *tp)
 {
 	struct symbol *sym = NULL;
-	tp->forward = 1;
 
+	tp->forward = 1;
 	if (yytoken == IDEN) {
 		register struct ctype *aux;
 
@@ -83,7 +84,7 @@
 			}
 			*tp = *aux;
 		} else {
-			sym->ctype = xmalloc(sizeof(*tp));
+			sym->ctype = tp;
 			tp->sym = sym;
 			tp->ns = ++nr_tags; /* FIX: It is only necessary */
 		}                           /*      in struct and union  */
--