Commit b253c03b authored by Sergio Costas's avatar Sergio Costas

Now checks fine the assignments to structs

parent 5654f93c
......@@ -429,7 +429,7 @@ class crusty(object):
options = self._eval_assignment(assignment.child2,var_container,function_container)
newoptions = []
for option in options:
retval = self._check_assignment(var_defined,[option],varname,assignment,None,0,function_container)
retval = self._check_assignment(var_defined,[option],varname,assignment.child1[0],None,0,function_container)
newoptions.append( (option[0],retval,option[2],option[3]) )
return newoptions
else:
......@@ -563,7 +563,9 @@ class crusty(object):
def _check_assignment(self,var_defined,options,varname,node,tree,counter,function_container):
this_is_crust = self.TYPE_CRUST if self._check_variable_properties(var_defined, self.PROPERTY_CRUST_VARIABLE) else self.TYPE_NO_CRUST
if self._check_variable_properties(var_defined,self.PROPERTY_ARRAY) or self._check_variable_properties(var_defined,self.PROPERTY_STRUCT):
if self._check_variable_properties(var_defined,self.PROPERTY_ARRAY):
this_is_crust = self.TYPE_NO_MATTER
if self._check_variable_properties(var_defined,self.PROPERTY_STRUCT) and (node.right is not None):
this_is_crust = self.TYPE_NO_MATTER
error_list = []
if len(options) > 1:
......@@ -627,7 +629,7 @@ class crusty(object):
varname = node.child1[0].name
var_defined = self._find_variable(var_container,varname,node.line)
options = self._eval_assignment(node.child2,var_container,function_container)
var_container = self._check_assignment(var_defined,options,varname,node,tree,counter,function_container)
var_container = self._check_assignment(var_defined,options,varname,node.child1[0],tree,counter,function_container)
continue
if node.type == "FUNCTION_CALL":
function_params = self._find_function(function_container,node.name,node.line)
......
......@@ -169,6 +169,8 @@ class Test(unittest.TestCase):
def testUsePostStructAssignment(self):
self._generic_test("unitest/test41.c",False,[ (crusty.crusty.MSG_ERROR,"Parameter {:d} when calling function '{:s}' at line {:d} was freed at line {:d}",1,"function",9,8) ])
def testUsePostStructAssignment2(self):
self._generic_test("unitest/test42.c",False,[ (crusty.crusty.MSG_CRITICAL,"Assigning the crust pointer '{:s}' to the non-crust variable '{:s}' at line {:d}",'param3',"test",8) ])
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
struct {
crust_t value;
} *test;
int function(crust_t param3) {
test = param3; // this is legal
}
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