Commit a8df0130 authored by Sergio Costas's avatar Sergio Costas

Another change to try to keep the consistency

parent 51f5e5d7
......@@ -642,17 +642,17 @@ class crust(object):
self._add_error(thread_status, self.MSG_ERROR, "Assigning the non-borrowed block '{:s}' to the borrowed variable '{:s}' at line {:d}", orig_data["name"], dest_data["name"], statement.line)
if orig_data["borrowed"] and (orig_var.right is None):
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)
self._add_error(orig_eval["thread_status"], self.MSG_CRITICAL, "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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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)
......
......@@ -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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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_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) ])
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) ])
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_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)] )
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)] )
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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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_ERROR, "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_CRITICAL, "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")
......@@ -320,10 +320,10 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test68.c", [(crust.crust.MSG_ERROR, "Overwritting the borrowed argument '{:s}' at line {:d}", "param", 7) ])
def test069AssignmentFromBorrowBlock(self):
self._generic_test("unitest/test69.c", [ (crust.crust.MSG_ERROR, "Assigning a borrowed block into a local variable is not allowed (assigning '{:s}' at line {:d})", "param", 9) ])
self._generic_test("unitest/test69.c", [ (crust.crust.MSG_CRITICAL, "Assigning a borrowed block into a local variable is not allowed (assigning '{:s}' at line {:d})", "param", 9) ])
def test070AssignmentFromBorrowBlock2(self):
self._generic_test("unitest/test70.c", [ (crust.crust.MSG_ERROR, "Assigning a borrowed block into a local variable is not allowed (assigning '{:s}' at line {:d})", "param", 9) ])
self._generic_test("unitest/test70.c", [ (crust.crust.MSG_CRITICAL, "Assigning a borrowed block into a local variable is not allowed (assigning '{:s}' at line {:d})", "param", 9) ])
def test071AssignmentToAndFromMemberOfBorrowBlock(self):
self._generic_test("unitest/test71.c", [ (crust.crust.MSG_WARNING, "Using variable '{:s}' at line {:d} with a possible NULL value", "param", 10) ])
......@@ -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_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) ])
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) ])
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) ])
......
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