Commit 51f5e5d7 authored by Sergio Costas's avatar Sergio Costas

Changed some CRITICAL to ERROR to keep consistency

parent 9a5ebd23
......@@ -334,7 +334,7 @@ class crust(object):
return function_name["function_params"]
except:
pass
self._add_error(thread_status, self.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is not declared or defined", str(function_name), line_number)
self._add_error(thread_status, self.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is neither declared nor defined", str(function_name), line_number)
raise self.FunctionNotFoundException()
......@@ -564,7 +564,6 @@ class crust(object):
dest_eval = self._eval_statement(statement.child1[0], thread_status)[0]
dest_var = dest_eval["node"]
dest_data = self._find_variable(thread_status, dest_var.name, statement.line)
dest_status = dest_data["value"]
if dest_var.right is not None:
dest_type = self.TYPE_NO_MATTER
......@@ -645,15 +644,15 @@ class crust(object):
if ((not dest_data["borrowed"]) or (dest_var.right is not None)) or (not dest_eval["pure"]):
self._add_error(orig_eval["thread_status"], self.MSG_ERROR, "Assigning a borrowed block into a local variable is not allowed (assigning '{:s}' at line {:d})", orig_data["name"], statement.line)
if (orig_type == self.TYPE_CRUST) and (dest_type == self.TYPE_NO_CRUST):
self._add_error(orig_eval["thread_status"], self.MSG_CRITICAL, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", orig_var.name, dest_data["name"], statement.line)
self._add_error(orig_eval["thread_status"], self.MSG_ERROR, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", orig_var.name, dest_data["name"], statement.line)
if (orig_type == self.TYPE_NO_CRUST) and (dest_type == self.TYPE_CRUST):
self._add_error(orig_eval["thread_status"], self.MSG_CRITICAL, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", orig_var.name, dest_data["name"], statement.line)
self._add_error(orig_eval["thread_status"], self.MSG_ERROR, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", orig_var.name, dest_data["name"], statement.line)
else:
orig_data = None
if (orig_type == self.TYPE_CRUST) and (dest_type == self.TYPE_NO_CRUST):
self._add_error(orig_eval["thread_status"], self.MSG_CRITICAL, "Assigning a crust pointer to the non-crust variable '{:s}' at line {:d}", dest_data["name"], statement.line)
self._add_error(orig_eval["thread_status"], self.MSG_ERROR, "Assigning a crust pointer to the non-crust variable '{:s}' at line {:d}", dest_data["name"], statement.line)
if (orig_type == self.TYPE_NO_CRUST) and (dest_type == self.TYPE_CRUST) and (orig_eval["value"] != self.VALUE_NULL):
self._add_error(orig_eval["thread_status"], self.MSG_CRITICAL, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", dest_data["name"], statement.line)
self._add_error(orig_eval["thread_status"], self.MSG_ERROR, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", dest_data["name"], statement.line)
if dest_data["borrowed"] and (dest_var.right is None) and (orig_eval["value"] != self.VALUE_NULL) and dest_eval["pure"]:
self._add_error(thread_status, self.MSG_ERROR, "Assigning a value to the borrowed variable '{:s}' at line {:d}", dest_data["name"], statement.line)
......@@ -1855,7 +1854,7 @@ class crust(object):
var_data = self._find_variable(thread_status, var_name, node.line, False, False)
if var_data["global"]:
if var_data["accessed"]:
self._add_error(thread_status, self.MSG_WARNING, "Trying to set to NULL the state of the already accessed global variable '{:s}' at line {:d}", var_name, node.line)
self._add_error(thread_status, self.MSG_ERROR, "Trying to set to NULL the state of the already accessed global variable '{:s}' at line {:d}", var_name, node.line)
self._set_var_value(thread_status, var_name, self.VALUE_NULL, node.line, True)
else:
self._add_error(thread_status, self.MSG_CRITICAL, "Trying to set to NULL the state of the non-global variable '{:s}' at line {:d}", var_name, node.line)
......@@ -1866,7 +1865,7 @@ class crust(object):
var_data = self._find_variable(thread_status, var_name, node.line, False, False)
if var_data["global"]:
if var_data["accessed"]:
self._add_error(thread_status, self.MSG_WARNING, "Trying to set to NOT_NULL the state of the already accessed global variable '{:s}' at line {:d}", var_name, node.line)
self._add_error(thread_status, self.MSG_ERROR, "Trying to set to NOT_NULL the state of the already accessed global variable '{:s}' at line {:d}", var_name, node.line)
self._set_var_value(thread_status, var_name, self.VALUE_NOT_NULL, node.line, True)
else:
self._add_error(thread_status, self.MSG_CRITICAL, "Trying to set to NOT_NULL the state of the non-global variable '{:s}' at line {:d}", var_name, node.line)
......
......@@ -138,7 +138,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test9.c", [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d} with an incorrect number of arguments", "function", 7) ])
def test010NonExistingFunction(self):
self._raise_test("unitest/test10.c", crust.crust.FunctionNotFoundException, [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is not declared or defined", "function3", 5) ])
self._raise_test("unitest/test10.c", crust.crust.FunctionNotFoundException, [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is neither declared nor defined", "function3", 5) ])
def test011CrustParameterNotPointer(self):
self._generic_test("unitest/test11.c", [ (crust.crust.MSG_CRITICAL, "An argument is defined as __crust__ type at line {:d}, but it is not a pointer", 1) ])
......@@ -180,16 +180,16 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test23.c", [ (crust.crust.MSG_ERROR, "Using uninitialized variable '{:s}' at line {:d}", "param4", 5) ])
def test024AssignNonCrustToCrust(self):
self._generic_test("unitest/test24.c", [ (crust.crust.MSG_CRITICAL, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "param4", "param5", 5) ])
self._generic_test("unitest/test24.c", [ (crust.crust.MSG_ERROR, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "param4", "param5", 5) ])
def test025AssignCrustToNonCrust(self):
self._generic_test("unitest/test25.c", [ (crust.crust.MSG_CRITICAL, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", "param4", "param5", 5) ])
self._generic_test("unitest/test25.c", [ (crust.crust.MSG_ERROR, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", "param4", "param5", 5) ])
def test026TypeCast(self):
self._generic_test("unitest/test26.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 6, 8) ])
def test027AssignNonCrustToCrust2(self):
self._generic_test("unitest/test27.c", [ (crust.crust.MSG_CRITICAL, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", "param", 5), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 5, 7) ])
self._generic_test("unitest/test27.c", [ (crust.crust.MSG_ERROR, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", "param", 5), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 5, 7) ])
def test028CrustRetVal(self):
self._generic_test("unitest/test28.c", [ (crust.crust.MSG_ERROR, "Calling the function '{:s}' at line {:d}, but ignoring the crust-type return value", "function", 7) ])
......@@ -210,7 +210,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test33.c", [ (crust.crust.MSG_CRITICAL, "Expected a __crust__ variable as argument {:d} when calling function '{:s}' at line {:d}", 1, "function", 6) ])
def test034MultiAssign(self):
self._generic_test("unitest/test34.c", [ (crust.crust.MSG_CRITICAL, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", "b", 6), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "a", 6, 8)] )
self._generic_test("unitest/test34.c", [ (crust.crust.MSG_ERROR, "Assigning a non-crust value to the crust variable '{:s}' at line {:d}", "b", 6), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "a", 6, 8)] )
def test035AmpPointer(self):
self._all_fine_test("unitest/test35.c")
......@@ -219,13 +219,13 @@ class Test(unittest.TestCase):
self._all_fine_test("unitest/test36.c")
def test037StructAssign(self):
self._generic_test("unitest/test37.c", [ (crust.crust.MSG_CRITICAL, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "test", "param4", 10) ])
self._generic_test("unitest/test37.c", [ (crust.crust.MSG_ERROR, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "test", "param4", 10) ])
def test038ArrayElement(self):
self._all_fine_test("unitest/test38.c")
def test039ArrayAssign(self):
self._generic_test("unitest/test39.c", [ (crust.crust.MSG_CRITICAL, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "test", "param4", 6) ])
self._generic_test("unitest/test39.c", [ (crust.crust.MSG_ERROR, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "test", "param4", 6) ])
def test040StructAssignment(self):
self._all_fine_test("unitest/test40.c")
......@@ -234,7 +234,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test41.c", [ (crust.crust.MSG_ERROR, "Argument {:d} when calling function '{:s}' at line {:d} was freed at line {:d}", 1, "function", 9, 8) ])
def test042UsePostStructAssignment2(self):
self._generic_test("unitest/test42.c", [ (crust.crust.MSG_CRITICAL, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", 'param3', "test", 8) ])
self._generic_test("unitest/test42.c", [ (crust.crust.MSG_ERROR, "Assigning the crust variable '{:s}' to the non-crust variable '{:s}' at line {:d}", 'param3', "test", 8) ])
def test043StructAssignmentByRef(self):
self._all_fine_test("unitest/test43.c")
......@@ -379,7 +379,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test83.c", [ (crust.crust.MSG_ERROR, "Using uninitialized function pointer '{:s}' at line {:d}", "test1", 7) ])
def test084UndefinedPointerFunction(self):
self._raise_test("unitest/test84.c", crust.crust.FunctionNotFoundException, [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is not declared or defined", "test1", 6) ])
self._raise_test("unitest/test84.c", crust.crust.FunctionNotFoundException, [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d}, but it is neither declared nor defined", "test1", 6) ])
def test085FunctionPointerIncorrectNumberOfParameters(self):
self._generic_test("unitest/test85.c", [ (crust.crust.MSG_CRITICAL, "Calling function '{:s}' at line {:d} with an incorrect number of arguments", "test1", 11) ])
......@@ -466,7 +466,7 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test111.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 12 , 13) ])
def test112CommaOperatorBad(self):
self._generic_test("unitest/test112.c", [ (crust.crust.MSG_ERROR, "Calling the function '{:s}' at line {:d}, but ignoring the crust-type return value", "function", 12), (crust.crust.MSG_CRITICAL, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "b", "param", 12), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 12 , 13) ])
self._generic_test("unitest/test112.c", [ (crust.crust.MSG_ERROR, "Calling the function '{:s}' at line {:d}, but ignoring the crust-type return value", "function", 12), (crust.crust.MSG_ERROR, "Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}", "b", "param", 12), (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 12 , 13) ])
def test113CommaOperatorFine2(self):
self._generic_test("unitest/test113.c", [ (crust.crust.MSG_ERROR, "Memory block '{:s}', initialized at line {:d}, is still in use at exit point in line {:d}", "param", 12 , 13) ])
......@@ -962,10 +962,10 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test229.c", [ (crust.crust.MSG_ERROR, "At exit point in line {:d}, global variable '{:s}' points to a block freed at line {:d}.", 16, "var1", 11) ])
def test230SetGlobalToNullAfterUse(self):
self._generic_test("unitest/test230.c", [ (crust.crust.MSG_WARNING, "Trying to set to NULL the state of the already accessed global variable '{:s}' at line {:d}", "var1", 10) ])
self._generic_test("unitest/test230.c", [ (crust.crust.MSG_ERROR, "Trying to set to NULL the state of the already accessed global variable '{:s}' at line {:d}", "var1", 10) ])
def test231SetGlobalToNullAfterUse(self):
self._generic_test("unitest/test231.c", [ (crust.crust.MSG_WARNING, "Trying to set to NOT_NULL the state of the already accessed global variable '{:s}' at line {:d}", "var1", 10) ])
self._generic_test("unitest/test231.c", [ (crust.crust.MSG_ERROR, "Trying to set to NOT_NULL the state of the already accessed global variable '{:s}' at line {:d}", "var1", 10) ])
def test232SetGlobalToNullInSeveralPaths(self):
self._all_fine_test("unitest/test232.c")
......
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