Commit c8d02168 authored by Sergio Costas's avatar Sergio Costas

Now takes into account for IF VARIABLE == NULL and IF VARIABLE != NULL...

Now takes into account for IF VARIABLE == NULL and IF VARIABLE != NULL variables that are not CRUST_TYPE
parent 14d83bb4
......@@ -817,7 +817,7 @@ class crust(object):
if param2.t_null and (param1.type == "IDENTIFIER"):
# check cases of CRUST_VAR == NULL or NULL == CRUST_VAR
var_data = self._find_variable(thread_status, param1.name, statement.line)
if var_data["crust"]:
if var_data["crust"] or (((var_data["pointer"] != 0) or ((var_data["function_params"] is not None) and (var_data["value"] != self.VALUE_FUNCTION))) and (param1.right is None)):
if statement.type == "EQ_OP":
cd1 = self.CONDITION_FALSE
cd2 = self.CONDITION_TRUE
......@@ -1670,6 +1670,10 @@ class crust(object):
if len(threads) == 0:
return [ (None, thread_status) ]
else:
# if thread_status["current_function"] == "comandos_set_var":
# for t in threads:
# print("Bloque:")
# self._print_tree(t[0])
return threads
if (node.type == "EVAL_TRUE") or (node.type == "EVAL_FALSE"):
......
......@@ -640,7 +640,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test141.c", [ (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 25, 13), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 25, 16), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 25, 19), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 25, 22) ])
def test142Switc3(self):
self._generic_test("unitest/test142.c", [ (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 17, 15), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 17, 13), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 15, 13) ])
self._generic_test("unitest/test142.c", [ (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 15, 13), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 15, 11), (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 13, 11) ])
def test143CheckSignatures(self):
self._generic_test("unitest/test143.c", [ (crust.crust.MSG_CRITICAL, "Function definition for '{:s}' at line {:d}, file '{:s}' differs from definition at line {:d}, file '{:s}'", "main", 7, "unitest/test143.c", 5, "unitest/test143.c") ])
......@@ -845,6 +845,12 @@ class Test(unittest.TestCase):
def test204TestSetNullNonGlobal(self):
lib = self._generic_test("unitest/test204.c", [ (crust.crust.MSG_CRITICAL, "Trying to set to NOT_NULL the state of the non-global variable '{:s}' at line {:d}", "var1", 7) ])
def test205SwitchWithArrayItem(self):
self._all_fine_test("unitest/test205.c")
def test206SwitchWithPointerContent(self):
self._all_fine_test("unitest/test206.c")
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
......@@ -4,9 +4,9 @@ typedef __crust_t__ unsigned char *crust_t;
void function(crust_t param);
void main(crust_t param1, crust_t param2, crust_t param3) {
void main(crust_t param1, crust_t param2, crust_t param3, int a) {
int a;
switch (a) {
case 0:
......
......@@ -4,9 +4,9 @@ typedef __crust_t__ unsigned char *crust_t;
void function(crust_t param);
void main(crust_t param1) {
void main(crust_t param1, int a) {
int a;
switch (a) {
case 0:
......
......@@ -4,9 +4,7 @@ typedef __crust_t__ unsigned char *crust_t;
void function(crust_t param);
void main(crust_t param1) {
int a;
void main(crust_t param1, int a) {
switch (a) {
case 0:
......
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
char function(unsigned char *datos) {
switch (datos[1]) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
return 1;
}
return 0;
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
char function(unsigned char *datos) {
switch (datos) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
return 1;
}
return 0;
}
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