shithub: scc

Download patch

ref: d6f2174895d35fd88a9e2095800f15a032ff1c9d
parent: c9d033d9c2ca5fdb266904ca6beeefc3b8a2dda8
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Aug 13 08:32:36 EDT 2015

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.

--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -587,7 +587,8 @@
 	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 @@
 		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");
 	}