Fix some bugs and a memleak in the testsuite.
authorDale Weiler <killfieldengine@gmail.com>
Sat, 22 Jun 2013 01:56:22 +0000 (01:56 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Sat, 22 Jun 2013 01:56:22 +0000 (01:56 +0000)
ast.c
ir.c
test.c

diff --git a/ast.c b/ast.c
index 584bda0714a5f923524ff828c66eaa6919ac9c84..87d34cedc84d83badf820f32ac492916138e8e56 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -2883,9 +2883,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     /* Now all blocks are in place */
     /* From 'bin' we jump to whatever comes first */
     if      (bprecond)   tmpblock = bprecond;
-    else if (bbody)      tmpblock = bbody;
+    else                 tmpblock = bbody;    /* can never be null */
+    
+    /* DEAD CODE
     else if (bpostcond)  tmpblock = bpostcond;
     else                 tmpblock = bout;
+    */
+    
     if (!ir_block_create_jump(bin, ast_ctx(self), tmpblock))
         return false;
 
diff --git a/ir.c b/ir.c
index 72e7406d663b9f570a90d890ee2e56257ca63d66..3fe990851f6a1dd5cb95931b03d2208c4e354980 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2584,7 +2584,8 @@ bool ir_function_calculate_liferanges(ir_function *self)
 
     /* parameters live at 0 */
     for (i = 0; i < vec_size(self->params); ++i)
-        ir_value_life_merge(self->locals[i], 0);
+        if (!ir_value_life_merge(self->locals[i], 0))
+            compile_error(self->context, "internal error: failed value-life merging");
 
     do {
         self->run_id++;
@@ -3875,7 +3876,7 @@ void ir_block_dump(ir_block* b, char *ind,
 {
     size_t i;
     oprintf("%s:%s\n", ind, b->label);
-    strncat(ind, "\t", IND_BUFSZ);
+    strncat(ind, "\t", IND_BUFSZ-1);
 
     if (b->instr && b->instr[0])
         oprintf("%s (%i) [entry]\n", ind, (int)(b->instr[0]->eid-1));
diff --git a/test.c b/test.c
index 29aefc10106093b3cce7a4ccf90e457fb06965b4..d49575cd93e747043e90a196decc7798c1f4f412 100644 (file)
--- a/test.c
+++ b/test.c
@@ -110,8 +110,7 @@ static FILE ** task_popen(const char *command, const char *mode) {
         data->handles[2] = fdopen(errhandle[0], mode);
 
         /* sigh */
-        if (argv)
-            vec_free(argv);
+        vec_free(argv);
         return data->handles;
     } else if (data->pid == 0) {
         /* child */
@@ -639,6 +638,7 @@ static void task_template_destroy(task_template_t **tmpl) {
      * Nullify all the template members otherwise NULL comparision
      * checks will fail if tmpl pointer is reused.
      */
+    mem_d((*tmpl)->tempfilename);
     mem_d(*tmpl);
 }