[hackers] [scc] decay pointers and functions in eval() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 13 Aug 2015 20:02:11 +0200 (CEST)

commit 15accc917305a32e269f8f3063108e9115d44d3d
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 13 19:57:32 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 13 19:57:32 2015 +0200

    decay pointers and functions in eval()
    
    This is mainly done for function calls, where
    pointers are passed. We have to found a better
    way to do this, because there are too much
    calls to decay() .

diff --git a/cc1/expr.c b/cc1/expr.c
index cbf5503..c223a44 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -267,6 +267,10 @@ chklvalue(Node *np, Type *tp)
                 error("invalid use of void expression");
 }
 
+/* TODO: put decay() call in a better place, because at this
+ moment we call dozens of calls in all the code */
+static Node *decay(Node *np);
+
 Node *
 eval(Node *np)
 {
_AT_@ -274,6 +278,12 @@ eval(Node *np)
 
         if (!np)
                 return NULL;
+
+ switch (BTYPE(np)) {
+ case ARY:
+ case FTN:
+ np = decay(np);
+ }
         if (np->op != OAND && np->op != OOR)
                 return np;
         p = node(OCOLON, inttype, constnode(one), constnode(zero));
Received on Thu Aug 13 2015 - 20:02:11 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 13 2015 - 20:12:30 CEST