[hackers] [scc] [cc1] Move ns to struct declarators || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 27 Feb 2017 06:34:56 +0100 (CET)

commit fd29c83f7281632dba2c210f488e8ccec173e604
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Feb 27 06:33:22 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Feb 27 06:33:22 2017 +0100

    [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.

diff --git a/cc1/decl.c b/cc1/decl.c
index f930d92..9b86cff 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -19,6 +19,7 @@ static char sccsid[] = "@(#) ./cc1/decl.c";
 
 struct declarators {
         unsigned nr;
+ unsigned ns;
         unsigned nr_types, nr_pars;
         Symbol **pars;
         Type **tpars;
_AT_@ -331,10 +332,10 @@ fundcl(struct declarators *dp)
         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;
_AT_@ -343,19 +344,19 @@ directdcl(struct declarators *dp, unsigned ns)
                 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);
         }
_AT_@ -370,7 +371,7 @@ directdcl(struct declarators *dp, unsigned ns)
 }
 
 static void
-declarator(struct declarators *dp, unsigned ns)
+declarator(struct declarators *dp)
 {
         unsigned n;
 
_AT_@ -379,7 +380,7 @@ declarator(struct declarators *dp, unsigned ns)
                         /* nothing */;
         }
 
- directdcl(dp, ns);
+ directdcl(dp);
 
         while (n--)
                 push(dp, PTR);
_AT_@ -867,8 +868,9 @@ dodcl(int rep, Symbol *(*fun)(struct decl *), unsigned ns, Type *parent)
                 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 */;
Received on Mon Feb 27 2017 - 06:34:56 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 27 2017 - 06:36:27 CET