Commit 8cd6ce58 authored by Sergio Costas's avatar Sergio Costas

Now checks if function types match even with __crust_not_null__

parent 6bc141c9
......@@ -443,7 +443,7 @@ class crust(object):
return False
def _compare_types(self, var1, var2):
def _compare_types(self, var1, var2, deep_check = False):
if var1["crust"] != var2["crust"]:
return False
if var1["borrowed"] != var2["borrowed"]:
......@@ -452,6 +452,9 @@ class crust(object):
return False
if var1["pointer"] != var2["pointer"]:
return False
if deep_check:
if var1["not_null"] != var2["not_null"]:
return False
return True
......@@ -1249,7 +1252,7 @@ class crust(object):
differ = True
else:
for c in range(len(function_data["function_params"])):
if not self._compare_types(function_data["function_params"][c], tmpparams["function_params"][c]):
if not self._compare_types(function_data["function_params"][c], tmpparams["function_params"][c], True):
differ = True
break
if differ:
......
......@@ -861,6 +861,9 @@ class Test(unittest.TestCase):
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)
def test209TestSetNullNonGlobal(self):
lib = self._generic_test("unitest/test209.c", [ (crust.crust.MSG_CRITICAL, "Function definition for '{:s}' at line {:d}, file '{:s}' differs from definition at line {:d}, file '{:s}'", "function", 9, "unitest/test209.c", 6, "unitest/test209.c") ])
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void function(crust_t);
void main(crust_t param1, crust_t param2) {
static int a = 0;
__crust_debug__
if (a == 0) {
function(param1);
} else {
function(param2);
}
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void function(crust_t __crust_not_null__);
void function2(crust_t);
void function(crust_t parameter) { // ERROR: the types doesn't match
function2(parameter);
}
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