shithub: scc

Download patch

ref: c9c87cb432cb4e479089fe8520c03cc1ca9f82e0
parent: 5f9dbbf31945ec8c2d9cf572866f098b6b6dcea0
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue May 13 14:17:48 EDT 2014

Remove Symbol field from field

Since we are not storing anymore fields as symbols thif field was
incorrect, because we were storing a pointer to a freed memory.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -50,7 +50,8 @@
 typedef struct ctype Type;
 
 struct field {
-	struct symbol *sym;
+	char *name;
+	int id;
 	struct field *next;
 };
 
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -267,16 +267,17 @@
 	s = sym->name;
 	op = tp->op;
 	for (q = p = tp->u.fields; p; q = p, p = p->next) {
-		t = p->sym->name;
+		t = p->name;
 		if (*s == *t && !strcmp(s, t))
 			goto duplicated_name;
-		if (op == ENUM && sym->u.i == p->sym->u.i)
+		if (op == ENUM && sym->u.i == p->id)
 			goto duplicated_value;
 	}
 
 	p = xmalloc(sizeof(*p));
+	p->name = xstrdup(s);
 	p->next = NULL;
-	p->sym = sym;
+	p->id = sym->id;
 	if (!q)
 		tp->u.fields = p;
 	else