scc

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

commit 5e00eb6985f2f280a7f4edc260bd0f6d0760faec
parent d571d1e0f46cacbc2867bd25779b745f0744fb2b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 08:59:52 +0200

Rewrite typedef handling in spec

This new version is clear (and more efficient) than the previous
one.

Diffstat:
Mdecl.c | 16++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/decl.c b/decl.c @@ -108,18 +108,18 @@ spec(void) case STRUCT: /* TODO */ case UNION: /* TODO */ case ENUM: /* TODO */ - case IDEN: { - struct symbol *sym = find(yytext, NS_TYPEDEF); - - if (sym && (!tp || !tp->type)) { - register unsigned char tok = ahead(); - - if (tok != ';' && tok != ',') { + case IDEN: + if (!tp || !tp->type) { + struct symbol *sym; + unsigned char tok = ahead(); + + sym = (yyval.sym->ns == NS_TYPEDEF) ? + yyval.sym : find(yytext, NS_TYPEDEF); + if (sym && tok != ';' && tok != ',') { (tp = sym->ctype)->refcnt++; next(); } } - } default: if (tp && !tp->type && sign) tp->type = INT;