ref: c5e705ef14f8038a051f258fe741919f4988ef7d
parent: 808ce90786c3b900eeaa6a5048c26838e7d0e456
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed May 14 10:53:57 EDT 2014
Fix struct declaration struct declaration was broken, and we were clearing the fields, so was not usseful at all.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -335,21 +335,19 @@
newtag(uint8_t tag)
{
register Symbol *sym;
- Type *tp;
+ register Type *tp;
if (yytoken == IDEN) {
- sym = lookup(yytext, NS_TAG);
- if (sym) {
- if (sym->type->op != tag)
- goto bad_tag;
- } else {
+ if ((sym = lookup(yytext, NS_TAG)) == NULL)
sym = install(yytext, NS_TAG);
- }
next();
} else {
sym = install("", NS_TAG);
}
- tp = sym->type = mktype(NULL, tag, 0);
+ if (!(tp = sym->type))
+ tp = sym->type = mktype(NULL, tag, 0);
+ if (tp->op != tag)
+ goto bad_tag;
return tp;
bad_tag:
@@ -365,7 +363,6 @@
tag = yylval.token;
next();
tp = newtag(tag);
- tp->u.fields = NULL;
if (accept('{')) {
if (tp->defined)
goto redefined;
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -170,11 +170,10 @@
case STRUCT: letter = L_STRUCT; break;
default: letter = tp->letter;
}
- bp = xmalloc(sizeof(*bp));
+ bp = xcalloc(1, sizeof(*bp));
bp->next = *tbl;
bp->type = tp;
bp->op = op;
- bp->u.nelem = nelem;
bp->letter = letter;
return *tbl = bp;
}