shithub: scc

Download patch

ref: 452bac14b4bf430cf4435943f4478abd5f309686
parent: 675adafd7148e7fdcc413759648e2bb45d795109
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jul 5 08:32:46 EDT 2013

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.

--- a/decl.c
+++ b/decl.c
@@ -116,10 +116,14 @@
 				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;
--- a/types.c
+++ b/types.c
@@ -26,8 +26,7 @@
 {
 	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);