scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 423f75f011f84fbc1ae9b439e34860f1d09d583f
parent 53b8642aa9cedc398e937c31d7b5ca75c78b0ed9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  5 Aug 2015 22:15:27 +0200

Fix type in several declarations

Diffstat:
cc1/code.c | 2+-
cc1/decl.c | 4++--
cc1/stmt.c | 3+--
cc1/types.c | 8++++++--
4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -175,7 +175,7 @@ emitconst(Node *np) switch (BTYPE(np)) { case INT: - printf("#%c%x", np->type->letter, sym->u.i); + printf("#%c%X", np->type->letter, sym->u.i); break; case ARY: /* diff --git a/cc1/decl.c b/cc1/decl.c @@ -14,7 +14,7 @@ struct dcldata { unsigned char op; unsigned short nelem; - unsigned ndcl; + unsigned char ndcl; void *data; }; @@ -140,7 +140,7 @@ declarator(Type *tp, unsigned ns) static Type *structdcl(void), *enumdcl(void); static Type * -specifier(unsigned *sclass) +specifier(int *sclass) { Type *tp = NULL; unsigned spec, qlf, sign, type, cls, size; diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -341,8 +341,7 @@ compound(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) static void stmt(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) { - void (*fun)(Symbol *lbreak, Symbol *lcont, Caselist *lswitch); - Node *np; + void (*fun)(Symbol *, Symbol *, Caselist *); switch (yytoken) { case '{': fun = compound; break; diff --git a/cc1/types.c b/cc1/types.c @@ -312,8 +312,12 @@ mktype(Type *tp, unsigned op, short nelem, Type *pars[]) tbl = &typetab[t]; for (bp = *tbl; bp; bp = bp->next) { if (eqtype(bp, &type)) { - /* FIXME: data can be a pointer to static data */ - free(data); + /* + * pars was allocated by the caller + * but the type already exists, so + * we have to deallocted it + */ + free(pars); return bp; } }