[hackers] [scc] Fix field emit || Roberto E. Vargas Caballero

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

commit d6f2174895d35fd88a9e2095800f15a032ff1c9d
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 13 12:32:36 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 13 12:32:36 2015 +0200

    Fix field emit
    
    The node had no symbol, and it was creating an unneeded node
    when the symbol could be stored in the own node.

diff --git a/cc1/expr.c b/cc1/expr.c
index a55af6d..cbf5503 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -587,7 +587,8 @@ field(Node *np)
         Symbol *sym;
 
         switch (BTYPE(np)) {
- case STRUCT: case UNION:
+ case STRUCT:
+ case UNION:
                 setnamespace(np->type->ns);
                 next();
                 if (yytoken != IDEN)
_AT_@ -595,7 +596,9 @@ field(Node *np)
                 if ((sym = yylval.sym) == NULL)
                         error("incorrect field in struct/union");
                 next();
- return node(OFIELD, sym->type, varnode(sym), np);
+ np = node(OFIELD, sym->type, np, NULL);
+ np->sym = sym;
+ return np;
         default:
                 error("struct or union expected");
         }
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:17 CEST