commit 09da26144179fcba493815c2068f7df631cc9b54
Author: Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Fri Apr 22 14:58:09 2016 +0200
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Fri Apr 22 14:58:09 2016 +0200
[cc2] Initialize the type of symbol nodes
A node contains a symbol has the same type that the symbol
contained. The code lacked this initialization, and this
was the reason it was creating nodes without type.
diff --git a/cc2/parser.c b/cc2/parser.c
index d03f036..a288da4 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -181,10 +181,13 @@ static void
symbol(char *token, union tokenop u)
{
Node *np;
+ Symbol *sym;
sclass = u.op >> 8;
np = newnode();
- np->u.sym = getsym(atoi(token+1));
+ sym = getsym(atoi(token+1));
+ np->u.sym = sym;
+ np->type = sym->type;
np->op = u.op & 0xFF;
push(np);
}