Commit af9dd9b9 authored by Sergio Costas's avatar Sergio Costas

Added extra tests for cases when returning a borrowed block

parent f3eecbb0
......@@ -1010,6 +1010,15 @@ class Test(unittest.TestCase):
def test245AssignBorrowedToBorrowed(self):
self._all_fine_test("unitest/test245.c")
def test245ReturnBorrowedVariable(self):
self._all_fine_test("unitest/test246.c")
def test247ReturnBorrowedParameter(self):
self._all_fine_test("unitest/test247.c")
def test248ReturnUninitializedBorrowedParameter(self):
self._generic_test("unitest/test248.c", [ (crust.crust.MSG_ERROR, "Returning variable '{:s}' at line {:d} is uninitialized", 'tmp', 8) ])
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
typedef __crust__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t __crust_borrow__ function2();
crust_t __crust_borrow__ function1(crust_t __crust_borrow__ param1) {
crust_t __crust_borrow__ tmp;
tmp = function2();
return tmp; // Valid
}
typedef __crust__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t __crust_borrow__ function1(crust_t __crust_borrow__ param1) {
return param1; // Valid
}
typedef __crust__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t __crust_borrow__ function1(crust_t __crust_borrow__ param1) {
crust_t __crust_borrow__ tmp;
return tmp; // ERROR: tmp is uninitialized
}
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