Commit 49c5a4c9 authored by Sergio Costas's avatar Sergio Costas

Now checks all the blocks in use when reaching a RETURN

parent b4d43da2
......@@ -849,6 +849,10 @@ class crusty(object):
if node.type == "RETURN":
if node.child1 is not None:
self._eval_assignment(node.child1[0],var_container,False)
# check if there are blocks in use
while(len(var_container) > 1):
self._check_blocks_in_use(var_container[0],node.line)
var_container = var_container[1:]
return [(None,None)]
print("Tipo: {:s}; Nombre: {:s}; Linea: {:s}".format(str(node.type),str(node.name),str(node.line)))
......
......@@ -264,6 +264,15 @@ class Test(unittest.TestCase):
def testBlockInUseAtEnd2(self):
self._generic_test("unitest/test64.c",[ (crusty.crusty.MSG_ERROR,"Memory block '{:s}', initialized at line {:d}, is still in use at exit point at line {:d}","param",5,7) ])
def testBlockInUseWithReturn(self):
self._generic_test("unitest/test65.c",[ (crusty.crusty.MSG_ERROR,"Memory block '{:s}', initialized at line {:d}, is still in use at exit point at line {:d}","var2",8,9) ])
def testBlockInUseWithReturn2(self):
self._generic_test("unitest/test66.c",[ (crusty.crusty.MSG_ERROR,"Memory block '{:s}', initialized at line {:d}, is still in use at exit point at line {:d}","var2",9,12) ])
def testBlockInUseWithReturn3(self):
self._all_fine_test("unitest/test67.c")
if __name__ == '__main__':
unittest.main()
......@@ -6,6 +6,7 @@ void main(crust_t param) {
crust_t var2;
var2 = param;
main(var2);
return;
main(param);
main(param); // this won't cause an error because it will never be executed
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param) {
crust_t var2;
var2 = param;
return; // ERROR: var2 hasn't been managed
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param) {
crust_t var2;
var2 = param;
if (var2 != NULL) {
return; // ERROR: var2 hasn't been managed
}
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param) {
crust_t var2;
var2 = param;
if (var2 == NULL) {
return;
}
main(var2);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment