scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit f8c543b955fb0e7dde34d6be06a2cd966b2f7087
parent cff1e86a7f61535db92a132d29fce0e805c8e529
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  7 Oct 2016 09:40:30 +0200

[cc1] Remove duptype()

This function was created only to avoid exporting newid(),
but the solution was worse than the original problem.

Diffstat:
Mcc1/cc1.h | 1+
Mcc1/symbol.c | 12+-----------
Mcc1/types.c | 5+++--
3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -368,6 +368,7 @@ extern void killsym(Symbol *sym); extern Symbol *newlabel(void); extern void keywords(struct keyword *key, int ns); extern Symbol *newstring(char *s, size_t len); +extern unsigned newid(void); /* stmt.c */ extern void compound(Symbol *lbreak, Symbol *lcont, Switch *sw); diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -122,7 +122,7 @@ popctx(void) head = sym; } -static unsigned short +unsigned newid(void) { unsigned short id; @@ -135,16 +135,6 @@ newid(void) return id; } -Type * -duptype(Type *base) -{ - Type *tp = xmalloc(sizeof(*tp)); - - *tp = *base; - tp->id = newid(); - return tp; -} - static Symbol * allocsym(int ns, char *name) { diff --git a/cc1/types.c b/cc1/types.c @@ -308,8 +308,9 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) } } - typesize(&type); - bp = duptype(&type); + bp = xmalloc(sizeof(*bp)); + *bp = type; + bp->id = newid(); bp->next = *tbl; return *tbl = bp; }