scc

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

commit 452bac14b4bf430cf4435943f4478abd5f309686
parent 675adafd7148e7fdcc413759648e2bb45d795109
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 12:32:46 +0200

Fix declaration of variables of typedef'd types

The modifiers of type and storage must go in a different ctype,
because different declarations can use the same typedef'd type,
so we can not share the typedef ctype between all of them.

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

diff --git a/decl.c b/decl.c @@ -116,10 +116,14 @@ spec(void) sym = (yyval.sym->ns == NS_TYPEDEF) ? yyval.sym : find(yytext, NS_TYPEDEF); if (sym && tok != ';' && tok != ',') { - (tp = sym->ctype)->refcnt++; - next(); + if (!tp) + tp = newctype(); + tp->type = TYPEDEF; + (tp->base = sym->ctype)->refcnt++; + break; } } + /* it is not a type name */ default: if (!tp || tp->type) return tp; diff --git a/types.c b/types.c @@ -26,8 +26,7 @@ delctype(register struct ctype *tp) { if (!tp) return; - tp->c_typedef = 0; /* this flag only is important in */ - if (--tp->refcnt == 0) { /* the parsing */ + if (--tp->refcnt == 0) { if (tp->base) delctype(tp->base); free(tp);