Commit be0c8518 authored by Sergio Costas's avatar Sergio Costas

Now supports functions without parameters, but with "(void)" in the definition

parent ef0adf8f
......@@ -1171,7 +1171,7 @@ class crust(object):
parameters = [ var_data.copy() ]
var_data["crust"] = False
for parameter in node.function_params:
if parameter.t_void and (parameter.pointer == 0):
if parameter.t_void and (parameter.pointer == 0) and not parameter.function:
continue
parameters.append( self._get_variable_properties(thread_status, parameter, parameter.pointer, True) )
var_data["function_params"] = parameters
......@@ -1221,7 +1221,7 @@ class crust(object):
counter = 0
if node.function_params is not None:
for parameter in node.function_params:
if parameter.t_void and (parameter.pointer == 0):
if parameter.t_void and (parameter.pointer == 0) and not parameter.function:
continue
if parameter.t_crust_recycle:
counter += 1
......@@ -1234,7 +1234,7 @@ class crust(object):
parameters = [ self._get_variable_properties(thread_status, node.return_value[0], node.return_value[0].pointer, False, node.name) ]
if node.function_params is not None:
for parameter in node.function_params:
if parameter.t_void and (parameter.pointer == 0):
if parameter.t_void and (parameter.pointer == 0) and not parameter.function:
continue
parameters.append( self._get_variable_properties(thread_status, parameter, parameter.pointer, True) )
# also add functions as variables to allow to assign them to function pointers
......@@ -1289,17 +1289,17 @@ class crust(object):
else:
tmpvars["variables"][0][v]["value"] = self.VALUE_NOT_NULL_OR_NULL
if node.function_params is not None:
for element in node.function_params:
if element.t_void and (element.pointer == 0):
for parameter in node.function_params:
if parameter.t_void and (parameter.pointer == 0) and not parameter.function:
continue
params = self._get_variable_properties(thread_status, element, element.pointer, True)
params = self._get_variable_properties(thread_status, parameter, parameter.pointer, True)
if params["not_null"]:
params["value"] = crust.VALUE_NOT_NULL
else:
params["value"] = crust.VALUE_NOT_NULL_OR_NULL
params["init_line"] = element.line
params["init_line"] = parameter.line
params["enum"] = False
tmpvars["variables"][0][element.name] = params
tmpvars["variables"][0][parameter.name] = params
parameters = self._find_function(thread_status, node.name, -1)
if parameters[0]["void"]:
tmpvars["return_is_crust"] = None
......
......@@ -841,7 +841,23 @@ class Test(unittest.TestCase):
self._all_fine_test("unitest/test187.c")
def test188GlobalAssignment(self):
self._all_fine_test("unitest/test188.c")
lib = self._all_fine_test("unitest/test188.c")
self._check_is_alias(lib, "var1", False, 0)
self._check_is_alias(lib, "var2", False, 0)
self._check_is_alias(lib, "var1", True, 1)
self._check_is_alias(lib, "var2", True, 1)
self._check_is_alias_of(lib, "var1","var2", 1)
def test189AssignmentWithAsterisk(self):
lib = self._all_fine_test("unitest/test189.c")
self._check_var_status(lib, "var1", crust.crust.VALUE_NOT_NULL_OR_NULL)
self._check_var_status(lib, "var2", crust.crust.VALUE_NOT_NULL_OR_NULL)
self._check_is_alias(lib, "var1", False)
self._check_is_alias(lib, "var2", False)
def test190FunctionWithVoidParameter(self):
self._all_fine_test("unitest/test190.c")
if __name__ == '__main__':
try:
......
unsigned int var1;
unsigned char *var2;
void function(void) {
__crust_debug__
var1 = var2;
__crust_debug__
var2++;
}
unsigned int var1;
unsigned char *var2;
void function(void) {
var1 = *var2;
__crust_debug__
}
typedef void (*test)(void);
void function(void);
void function2(test);
void main() {
function();
function2(NULL);
}
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