ref: fa31b3c3f732be9e1b96552c9d63380fe1c65886
parent: 0f4ff07f5e70ab058cc15831e24a5f7bce5e97a5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Mar 20 15:05:23 EDT 2015
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.
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -215,8 +215,7 @@
case 2:
moveto(np, HL);
break;
- case 4:
- case 8:
+ default:
abort();
}
}
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -457,13 +457,15 @@
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;
}
--
⑨