Commit 0774c3d4 authored by Sergio Costas's avatar Sergio Costas

Now detects if a borrowed block is being assigned

parent cd6759f6
This diff is collapsed.
......@@ -276,5 +276,11 @@ class Test(unittest.TestCase):
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)])
def testAssignmentFromBorrowBlock(self):
self._generic_test("unitest/test69.c",[ (crusty.crusty.MSG_ERROR,"Assigning a borrowed block into a local variable is not allowed (assignment to '{:s}' at line {:d})","var2",13) ])
def testAssignmentFromBorrowBlock2(self):
self._generic_test("unitest/test70.c",[ (crusty.crusty.MSG_ERROR,"Assigning a borrowed block into a local variable is not allowed (assignment to '{:s}' at line {:d})","var2",13) ])
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void function(crust_t param) {
function(param); // a trick to free param and trigger only one error
}
void main(crust_t __crust_borrow__ param) {
crust_t var2;
var2 = param;
function(var2); // a trick to free var2 and trigger only one error
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void function(crust_t param) {
function(param); // a trick to free param and trigger only one error
}
void main(crust_t __crust_borrow__ param) {
crust_t var2;
var2 = 1 ? param : NULL;
function(var2); // a trick to free var2 and trigger only one error
}
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