shithub: mc

Download patch

ref: f97e207c661b21747119784d7dea76fb91f6d13f
parent: 7e9636534ee41879a2a92af42f40932b26752685
author: Ori Bernstein <[email protected]>
date: Wed Dec 18 08:29:10 EST 2013

Drain increment queue before jumping to returns.

--- a/6/simp.c
+++ b/6/simp.c
@@ -302,6 +302,7 @@
         case Tyname:
             return tysize(t->sub[0]);
         case Tyarray:
+            t->asize = fold(t->asize, 0);
             assert(exprop(t->asize) == Olit);
             return t->asize->expr.args[0]->lit.intval * tysize(t->sub[0]);
         case Tytuple:
@@ -1290,6 +1291,10 @@
                 t = set(t, rval(s, args[0], NULL));
                 append(s, t);
             }
+            /* drain the increment queue before we return */
+            for (i = 0; i < s->nqueue; i++)
+                append(s, s->incqueue[i]);
+            lfree(&s->incqueue, &s->nqueue);
             jmp(s, s->endlbl);
             break;
         case Oasn:
@@ -1438,7 +1443,7 @@
     Func *fn;
     Cfg *cfg;
 
-    if(debugopt['i'])
+    if(debugopt['i'] || debugopt['F'] || debugopt['f'])
         printf("\n\nfunction %s\n", name);
 
     /* set up the simp context */
@@ -1449,7 +1454,7 @@
     flatten(s, n);
     popstab();
 
-    if (debugopt['f'])
+    if (debugopt['f'] || debugopt['F'])
         for (i = 0; i < s->nstmts; i++)
             dump(s->stmts[i], stdout);
     for (i = 0; i < s->nstmts; i++) {
--- a/test/tests
+++ b/test/tests
@@ -30,6 +30,7 @@
 B swidencast	E	99
 B derefassign	E	123
 B ptrpreinc	E	9
+B incret        E       1
 B outparam	E	42
 B outparam-sl	E	2
 B struct1	E	12
@@ -88,7 +89,6 @@
 B matchunion_sl	P	foo
 B matchbind	E	8
 F matchmixed
-
 B bigliteral	P	34359738368
 B arraylit-ni	E	2
 B livearraylit	E	21