Commit f1a38cf0 authored by Sergio Costas's avatar Sergio Costas

Now allows to return the return value of a function

parent a3c6acc4
......@@ -1392,7 +1392,7 @@ class crust(object):
if node.type == "RETURN":
if node.child1 is not None:
thread_status["returned_something"] = True
threads = self._eval_statement(node.child1[0], thread_status, True)
threads = self._eval_statement(node.child1[0], thread_status)
else:
thread_status["returned_something"] = False
threads = [ {"thread_status":thread_status, "value":self.VALUE_NOT_NULL_OR_NULL, "type":self.TYPE_NO_MATTER, "condition":self.CONDITION_FALSE_TRUE, "node":None} ]
......@@ -1642,7 +1642,7 @@ class crust(object):
# this code is the entry point
def process_file(lib, filename, parameters):
print("Processing file {:s}".format(filename))
print("Analizing file {:s}".format(filename))
if (parameters["debug1"] is not None) and (parameters["debug2"] is not None):
lib.set_debug_lines(parameters["debug1"], parameters["debug2"])
tree = lib.read_file(filename, False, parameters["includes"], parameters["defines"], parameters["nocpp"])
......
......@@ -816,6 +816,9 @@ class Test(unittest.TestCase):
def test179AssignCrustToNoCrustThroughTypecast(self):
self._generic_test("unitest/test179.c", [ (crust.crust.MSG_ERROR, "Return value at line {:d} is NULL, but the function must not return a NULL value", 7) ])
def test180ReturnFunctionReturn(self):
self._all_fine_test("unitest/test180.c")
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t function();
crust_t main() {
return function(); // this is fine.
}
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