@@ -32,4 +32,40 @@ int* get2()
3232 static int x;
3333 static int * y = &x;
3434 return y;
35+ }
36+
37+ struct Dummy {
38+ int m;
39+ };
40+
41+ const int * get3 ();
42+ const int * get4 (const Dummy& d);
43+ const int * get5 (const Owner<int >& d);
44+ const int * get6 (const Owner<Dummy>& d);
45+ const int * get7 (const Owner<Pair<int , int >>& d);
46+
47+ void test_contract_return ()
48+ {
49+ __lifetime_contracts (&get3);
50+ // expected-warning@-1 {{pset(Post((return value))) = ((global), (null))}}
51+
52+ __lifetime_contracts (&get4);
53+ // expected-warning@-1 {{pset(Pre(d)) = (*d)}}
54+ // expected-warning@-2 {{pset(Pre((*d).m)) = (*d)}}
55+ // expected-warning@-3 {{pset(Post((return value))) = ((null), *d)}}
56+
57+ __lifetime_contracts (&get5);
58+ // expected-warning@-1 {{pset(Pre(d)) = (*d)}}
59+ // expected-warning@-2 {{pset(Pre(*d)) = (**d)}}
60+ // expected-warning@-3 {{pset(Post((return value))) = ((null), **d)}}
61+
62+ __lifetime_contracts (&get6);
63+ // expected-warning@-1 {{pset(Pre(d)) = (*d)}}
64+ // expected-warning@-2 {{pset(Pre(*d)) = (**d)}}
65+ // expected-warning@-3 {{pset(Post((return value))) = ((null), **d)}}
66+
67+ __lifetime_contracts (&get7);
68+ // expected-warning@-1 {{pset(Pre(d)) = (*d)}}
69+ // expected-warning@-2 {{pset(Pre(*d)) = (**d)}}
70+ // expected-warning@-3 {{pset(Post((return value))) = ((null), **d)}}
3571}
0 commit comments