scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c9c87cb432cb4e479089fe8520c03cc1ca9f82e0
parent 5f9dbbf31945ec8c2d9cf572866f098b6b6dcea0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 13 May 2014 18:17:48 +0200

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.

Diffstat:
Mcc1/cc1.h | 3++-
Mcc1/decl.c | 7++++---
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -50,7 +50,8 @@ struct ctype { typedef struct ctype Type; struct field { - struct symbol *sym; + char *name; + int id; struct field *next; }; diff --git a/cc1/decl.c b/cc1/decl.c @@ -267,16 +267,17 @@ newfield(Type *tp, Symbol *sym) 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