shithub: scc

Download patch

ref: 849b7a5e8aa295683e330c547b116e4a56c87db5
parent: 88aee8a45958896c9982aae423221c2f06f1a3ef
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Feb 27 01:33:22 EST 2017

[cc1] Move ns to struct declarators

At this moment ns is not passed to fundcl() and arydcl(),
but all the other parameters are passed in the struct declarators
parameters, so it is more logical to do the same with ns.

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -19,6 +19,7 @@
 
 struct declarators {
 	unsigned nr;
+	unsigned ns;
 	unsigned nr_types, nr_pars;
 	Symbol **pars;
 	Type **tpars;
@@ -331,10 +332,10 @@
 	push(dp, typefun, ntypes, types, pars);
 }
 
-static void declarator(struct declarators *dp, unsigned ns);
+static void declarator(struct declarators *dp);
 
 static void
-directdcl(struct declarators *dp, unsigned ns)
+directdcl(struct declarators *dp)
 {
 	Symbol *p, *sym;
 	static int nested;
@@ -343,19 +344,19 @@
 		if (nested == NR_SUBTYPE)
 			error("too many declarators nested by parentheses");
 		++nested;
-		declarator(dp, ns);
+		declarator(dp);
 		--nested;
 		expect(')');
 	} else {
 		if (yytoken == IDEN || yytoken == TYPEIDEN) {
 			sym = yylval.sym;
-			if (p = install(ns, sym)) {
+			if (p = install(dp->ns, sym)) {
 				sym = p;
 				sym->flags &= ~SDECLARED;
 			}
 			next();
 		} else {
-			sym = newsym(ns, NULL);
+			sym = newsym(dp->ns, NULL);
 		}
 		push(dp, IDEN, sym);
 	}
@@ -370,7 +371,7 @@
 }
 
 static void
-declarator(struct declarators *dp, unsigned ns)
+declarator(struct declarators *dp)
 {
 	unsigned  n;
 
@@ -379,7 +380,7 @@
 			/* nothing */;
 	}
 
-	directdcl(dp, ns);
+	directdcl(dp);
 
 	while (n--)
 		push(dp, PTR);
@@ -867,8 +868,9 @@
 		stack.nr_pars = stack.nr_types = stack.nr = 0;
 		stack.pars = dcl.bufpars;
 		stack.tpars = dcl.buftpars;
+		stack.ns = ns;
 
-		declarator(&stack, ns);
+		declarator(&stack);
 
 		while (pop(&stack, &dcl))
 			/* nothing */;