summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-11 22:20:11 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-11 22:20:11 -0800
commite9a476ebae14c3d6a806bddc1b7514b60a846fc4 (patch)
tree3ef4b7eb6e6b609d04e872b9e81887bc669512a5 /6
parentd21cc40703f9e3fb86e590fce62ee0847fc6cfd8 (diff)
downloadmc-e9a476ebae14c3d6a806bddc1b7514b60a846fc4.tar.gz
Fix code to disallow use before definition.
At least in some cases.
Diffstat (limited to '6')
-rw-r--r--6/main.c5
-rw-r--r--6/simp.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/6/main.c b/6/main.c
index 5d66e38..dbd77aa 100644
--- a/6/main.c
+++ b/6/main.c
@@ -23,7 +23,7 @@
Node *file;
char debugopt[128];
int writeasm;
-int extracheck;
+int extracheck = 1;
int p9asm;
char *outfile;
char **incpaths;
@@ -164,7 +164,7 @@ int main(int argc, char **argv)
outfile = NULL;
- optinit(&ctx, "d:hSo:I:9G", argv, argc);
+ optinit(&ctx, "cd:hSo:I:9G", argv, argc);
asmsyntax = Defaultasm;
while (!optdone(&ctx)) {
switch (optnext(&ctx)) {
@@ -181,6 +181,7 @@ int main(int argc, char **argv)
break;
case 'c':
extracheck = 1;
+ break;
case 'd':
while (ctx.optarg && *ctx.optarg)
debugopt[*ctx.optarg++ & 0x7f]++;
diff --git a/6/simp.c b/6/simp.c
index 59a12e9..03ad0b1 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -963,6 +963,10 @@ static Node *assign(Simp *s, Node *lhs, Node *rhs)
t = lval(s, lhs);
u = rval(s, rhs, t);
+ /* hack: we're assigning to lhs, but blitting shit over doesn't
+ * trigger that */
+ if (stacknode(lhs))
+ def(s, lhs);
/* if we stored the result into t, rval() should return that,
* so we know our work is done. */
if (u == t) {