scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit fa31b3c3f732be9e1b96552c9d63380fe1c65886
parent 0f4ff07f5e70ab058cc15831e24a5f7bce5e97a5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 20 Mar 2015 19:05:23 -0400

Assign type to return nodes

It is important to give types in all the nodes, because
in other case we can have problems in the optimization
part.

Diffstat:
Mcc2/cgen.c | 3+--
Mcc2/parser.c | 6++++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -215,8 +215,7 @@ accum(Node *np) case 2: moveto(np, HL); break; - case 4: - case 8: + default: abort(); } } diff --git a/cc2/parser.c b/cc2/parser.c @@ -457,13 +457,15 @@ expression(char *token) static void oreturn(char *token) { - Node *np = newnode(); + Node *np = newnode(), *lp; np->op = token[0]; if (token = strtok(NULL, "\t")) { expr(token); - np -> left = pop(); + lp = pop(); + np ->left = lp; + np->type = lp->type; } else { np->left = NULL; }