scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit d6f2174895d35fd88a9e2095800f15a032ff1c9d
parent c9d033d9c2ca5fdb266904ca6beeefc3b8a2dda8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 13 Aug 2015 12:32:36 +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.

Diffstat:
cc1/expr.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -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) @@ -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"); }