shithub: scc

Download patch

ref: 46eaaf7b32ddb0e7ce17c03db45d6c6ef98bc0f0
parent: 5a21c182dcb8e58fb9df08628299c81871dd02e9
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Oct 30 03:51:30 EDT 2013

Remove the NS_TYPEDEF namespace

Typedef are usual symbols, and they use the NS_IDEN namespace,
so NS_TYPEDEF namespace was an error and complicated the code.
This new version is more standard comptlaint.

--- a/decl.c
+++ b/decl.c
@@ -193,13 +193,11 @@
 			next();
 			return structdcl(tp);
 		case IDEN:
-			/* TODO: remove NS_TYPEDEF */
-			if (tp && tp->c_typedef && !tp->type)
-				goto check_type;
 			if (!tp || !tp->type) {
-				struct symbol *sym = lookup(yytext, NS_TYPEDEF);
+				register struct symbol *sym;
 
-				if (sym->ctype) {
+				sym = lookup(yytext, NS_IDEN);
+				if (sym->ctype && sym->ctype->c_typedef) {
 					tp = ctype(tp, TYPEDEF);
 					tp->base = sym->ctype;
 					break;
@@ -297,7 +295,7 @@
 		struct node *np;
 		register struct ctype *tp;
 
-		declarator(base, base->c_typedef ? NS_TYPEDEF : NS_IDEN);
+		declarator(base, NS_IDEN);
 		tp = cursym->ctype = decl_type(base);
 		if ((tp->type == STRUCT || tp->type == UNION) && tp->forward)
 			error("declaration of variable with incomplete type");
--- a/symbol.h
+++ b/symbol.h
@@ -14,7 +14,6 @@
 	NS_IDEN,
 	NS_KEYWORD,
 	NS_LABEL,
-	NS_TYPEDEF,
 	NS_STRUCT
 };