Commit 9a5ebd23 authored by Sergio Costas's avatar Sergio Costas

Now it is a WARNING to change the status of a global variable after being accessed

parent 4a9ba1e4
......@@ -1855,7 +1855,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_CRITICAL, "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_WARNING, "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 +1866,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_CRITICAL, "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_WARNING, "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)
......
......@@ -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_CRITICAL, "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_WARNING, "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_CRITICAL, "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_WARNING, "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