Commit cd6759f6 authored by Sergio Costas's avatar Sergio Costas

Now doesn't allow to overwrite a borrowed block

parent 49c5a4c9
......@@ -425,6 +425,9 @@ class crusty(object):
if var_defined["struct"] and (destination.right is not None):
this_is_crust = self.TYPE_NO_MATTER
if var_defined["borrowed"]:
self._add_error(self.MSG_ERROR,"Overwritting a borrowed block ('{:s}' at line {:d}) with a new block is not allowed",destination.name,destination.line)
for option in options:
if (option[2] != self.TYPE_NO_MATTER) and (this_is_crust != self.TYPE_NO_MATTER) and (option[2] != this_is_crust):
if this_is_crust == self.TYPE_CRUST:
......
......@@ -273,6 +273,8 @@ class Test(unittest.TestCase):
def testBlockInUseWithReturn3(self):
self._all_fine_test("unitest/test67.c")
def testAssignmentToBorrowBlock(self):
self._generic_test("unitest/test68.c",[(crusty.crusty.MSG_ERROR,"Overwritting a borrowed block ('{:s}' at line {:d}) with a new block is not allowed", "param", 7), (crusty.crusty.MSG_ERROR,"Assignment to '{:s}' at line {:d}, which was already assigned at line {:d}", "param", 7, 5)])
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t __crust_borrow__ param) {
param = 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