[hackers] [scc] [cc2] Assign curfun only in functions || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 3 Oct 2016 16:17:25 +0200 (CEST)

commit 4c6c01a90ba930f89907cc16efc1a3b2d2f2db6c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Oct 3 16:11:37 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Oct 3 16:11:37 2016 +0200

    [cc2] Assign curfun only in functions
    
    Curfun was changed in every prototype, and it meant
    that the current function could be changed when a
    prototype was declared in the body of a function.

diff --git a/cc2/parser.c b/cc2/parser.c
index 496b900..34f35c3 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -37,6 +37,7 @@ struct swtch {
 };
 
 static struct swtch swtbl[NR_BLOCK], *swp = swtbl;
+static Symbol *lastfun;
 
 typedef void parsefun(char *, union tokenop);
 static parsefun type, symbol, getname, unary, binary, ternary, call,
_AT_@ -543,7 +544,7 @@ decl(Symbol *sym)
         Type *tp = &sym->type;
 
         if (tp->flags & FUNF) {
- curfun = sym;
+ lastfun = sym;
         } else {
                 switch (sym->kind) {
                 case SEXTRN:
_AT_@ -653,6 +654,7 @@ stmt(void)
 static void
 beginfun(void)
 {
+ curfun = lastfun;
         inpars = 1;
         pushctx();
         addstmt(newnode(OBFUN), SETCUR);
Received on Mon Oct 03 2016 - 16:17:25 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 03 2016 - 16:24:16 CEST