Commit 498b69a9 authored by Sergio Costas's avatar Sergio Costas

Now does right comparisons when comparing a struct element with zero or non-zero

Now considers static variables to be NOT_NULL_OR_NULL regardles the initialization value, because it can change between calls
parent 1524588e
......@@ -503,14 +503,17 @@ class crust(object):
if statement.right is not None:
valuetype = self.TYPE_NO_MATTER
valuedata = self.VALUE_NOT_NULL_OR_NULL
pure = False
elif self._check_statement_is_crust(statement, vardata):
valuetype = self.TYPE_CRUST
pure = True
else:
valuetype = self.TYPE_NO_CRUST
pure = True
return [ {"thread_status":thread_status, "value":vardata["value"], "type":valuetype, "condition":self._status_to_condition(vardata["value"]), "node":statement, "pure": pure} ]
valuedata = vardata["value"]
if self._check_statement_is_crust(statement, vardata):
valuetype = self.TYPE_CRUST
pure = True
else:
valuetype = self.TYPE_NO_CRUST
pure = True
return [ {"thread_status":thread_status, "value":valuedata, "type":valuetype, "condition":self._status_to_condition(valuedata), "node":statement, "pure": pure} ]
if statement.type == "TYPECAST":
......@@ -1461,14 +1464,17 @@ class crust(object):
varname = node.name
var_defined = self._get_variable_properties(thread_status, node, node.pointer, False)
if node.arrays is None:
var_defined["value"] = crust.VALUE_UNINITIALIZED
if node.t_static:
var_defined["value"] = crust.VALUE_NOT_NULL_OR_NULL
else:
var_defined["value"] = crust.VALUE_UNINITIALIZED
else:
var_defined["value"] = crust.VALUE_NOT_NULL
var_defined["init_line"] = None
var_defined["enum"] = False
#var_defined = self._node_fill_parameters(thread_status, node, var_defined)
thread_status["variables"][0][node.name] = var_defined
if (node.assignment is None):
if (node.assignment is None) or (node.t_static):
return self._check_return_block(tree[1:], thread_status)
# if the variable definition also has an assignment, then create a fake '=' node
tmpnode = node.copy()
......
......@@ -508,7 +508,7 @@ class Test(unittest.TestCase):
self._all_fine_test("unitest/test126.c")
def test127ForProcessesBlocks(self):
self._all_fine_test("unitest/test127.c")
self._generic_test("unitest/test127.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 7, 13) ])
def test128AssignAliasFromAlias(self):
lib = self._all_fine_test("unitest/test128.c")
......@@ -820,7 +820,7 @@ class Test(unittest.TestCase):
self._all_fine_test("unitest/test197.c")
def test198ForLoopWithoutFreeingWithAlias(self):
self._all_fine_test("unitest/test198.c")
self._generic_test("unitest/test198.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "var", 13, 19) ])
def test199AssingFunctionPointerToAlias(self):
self._generic_test("unitest/test199.c", [ (crust.crust.MSG_ERROR, "Trying to assign the function '{:s}' into the variable '{:s}', which is not a pointer to function, at line {:d}", "function2", "tmp1", 16), (crust.crust.MSG_ERROR, "Assigning a pointer of the function '{:s}' to the alias '{:s}' at line {:d}", "function2", "tmp1", 16) ])
......@@ -855,6 +855,10 @@ class Test(unittest.TestCase):
lib = self._all_fine_test("unitest/test207.c")
self._check_var_state(lib, "str", crust.crust.VALUE_NOT_NULL)
def test208TestSetNullNonGlobal(self):
lib = self._generic_test("unitest/test208.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param2", 7, 15), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param1", 7, 15) ])
self._check_var_state(lib, "a", crust.crust.VALUE_NOT_NULL_OR_NULL)
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
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