Skip to content

Commit ad29bf7

Browse files
committed
Inline sub-function calls
Signed-off-by: Felipe R. Monteiro <[email protected]>
1 parent 3ac7f47 commit ad29bf7

File tree

13 files changed

+132
-138
lines changed

13 files changed

+132
-138
lines changed
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
CORE
22
main.c
3-
--enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4-
^EXIT=10$
3+
--enforce-contract f1
4+
^EXIT=0$
55
^SIGNAL=0$
6-
^VERIFICATION FAILED$
6+
^\[f1.\d+\] line \d+ Check that x2 is assignable: SUCCESS$
7+
^\[f1.\d+\] line \d+ Check that y2 is assignable: SUCCESS$
8+
^\[f1.\d+\] line \d+ Check that z2 is assignable: SUCCESS$
9+
^\[f2.\d+\] line \d+ Check that x3 is assignable: SUCCESS$
10+
^\[f2.\d+\] line \d+ Check that y3 is assignable: SUCCESS$
11+
^\[f2.\d+\] line \d+ Check that z3 is assignable: SUCCESS$
12+
^\[f3.\d+\] line \d+ Check that \*x3 is assignable: SUCCESS$
13+
^\[f3.\d+\] line \d+ Check that \*y3 is assignable: SUCCESS$
14+
^\[f3.\d+\] line \d+ Check that \*z3 is assignable: SUCCESS$
15+
^VERIFICATION SUCCESSFUL$
716
--
817
--
9-
This test checks that verification fails when an assigns clause is not respected through multiple function calls.
18+
This test checks that verification only considers assigns clause from enforced function.

regression/contracts/assigns_enforce_15/test.desc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
CORE
22
main.c
3-
--enforce-contract foo --enforce-contract bar --enforce-contract baz --enforce-contract qux
3+
--enforce-contract foo --enforce-contract baz --enforce-contract qux
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[bar\.1\] line \d+ .*: FAILURE$
7-
^\[baz\.1\] line \d+ .*: FAILURE$
8-
^\[qux\.1\] line \d+ .*: FAILURE$
6+
^\[baz.\d+\] line \d+ Check that global is assignable: FAILURE$
7+
^\[qux.\d+\] line \d+ Check that global is assignable: FAILURE$
98
^VERIFICATION FAILED$
109
--
1110
--
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int x = 0;
5+
6+
void quz() __CPROVER_assigns(x)
7+
{
8+
x = -1;
9+
}
10+
11+
int baz() __CPROVER_assigns()
12+
{
13+
return 5;
14+
}
15+
16+
void bar(int *y, int w) __CPROVER_assigns(*y)
17+
{
18+
*y = 3;
19+
w = baz();
20+
quz();
21+
}
22+
23+
void foo(int *y, int z) __CPROVER_assigns(*y)
24+
{
25+
int w = 5;
26+
assert(w == 5);
27+
bar(y, w);
28+
z = -2;
29+
}
30+
31+
int main()
32+
{
33+
int *y = malloc(sizeof(*y));
34+
*y = 0;
35+
int z = 1;
36+
foo(y, z);
37+
assert(x == -1);
38+
assert(*y == 3);
39+
assert(z == 1);
40+
return 0;
41+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
main.c
3+
--enforce-contract foo
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
main.c function bar
7+
^\[bar.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
8+
^\[baz.\d+\] line \d+ Check that w is assignable: SUCCESS$
9+
^\[foo.\d+\] line \d+ Check that w is assignable: SUCCESS$
10+
^\[foo.\d+\] line \d+ Check that z is assignable: SUCCESS$
11+
^\[quz.\d+\] line \d+ Check that x is assignable: FAILURE$
12+
^VERIFICATION FAILED$
13+
--
14+
--
15+
Checks whether checks write set for sub-function calls.

regression/contracts/assigns_enforce_multi_file_01/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
CORE
22
main.c
3-
--enforce-contract f1 --enforce-contract f2 --enforce-contract f3
4-
^EXIT=10$
3+
--enforce-contract f1
4+
^EXIT=0$
55
^SIGNAL=0$
6-
^VERIFICATION FAILED$
6+
^VERIFICATION SUCCESSFUL$
77
--
88
--
99
This test replicates the behavior of assigns_enforce_04, but separates

regression/contracts/assigns_validity_pointer_02/test.desc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS$
7-
^\[foo.\d+\] line \d+ Check that bar\'s assigns clause is a subset of foo\'s assigns clause: SUCCESS$
7+
^\[bar.\d+\] line \d+ Check that \*x is assignable: SUCCESS$
8+
^\[bar.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
9+
^\[baz.\d+\] line \d+ Check that \*z is assignable: SUCCESS$
10+
^\[foo.\d+\] line \d+ Check that x is assignable: SUCCESS$
11+
^\[foo.\d+\] line \d+ Check that y is assignable: SUCCESS$
812
^\[foo.\d+\] line \d+ Check that \*x is assignable: SUCCESS$
9-
^\[foo.\d+\] line \d+ Check that baz\'s assigns clause is a subset of foo\'s assigns clause: SUCCESS$
1013
^VERIFICATION SUCCESSFUL$
1114
--
1215
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$

regression/contracts/function-calls-03-1/test-enf.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
CORE
22
main.c
3-
--enforce-contract f1 --enforce-contract f2 _ --unwind 20 --unwinding-assertions
3+
--enforce-contract f1 _ --unwind 20 --unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
6+
^file main.c line \d+ function f2: recursion is ignored on call to \'f2\'$
7+
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
68
^VERIFICATION FAILED$
79
--
810
--
911
Verification:
1012
function | pre-cond | post-cond
1113
---------|----------|----------
1214
f1 | assumed | asserted
13-
f2 | assumed | asserted
1415

1516
Test should fail:
1617
The postcondition of f2 is incorrect, considering the recursion particularity.

regression/contracts/function-calls-03/test-enf.desc

Lines changed: 0 additions & 16 deletions
This file was deleted.

regression/contracts/function-calls-04-1/test-enf.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
CORE
22
main.c
3-
--enforce-contract f1 --enforce-contract f2_out --enforce-contract f2_in _ --unwind 20 --unwinding-assertions
3+
--enforce-contract f1 _ --unwind 20 --unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
6+
^file main.c line \d+ function f2\_in: recursion is ignored on call to \'f2\_out\'$
7+
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: FAILURE$
68
^VERIFICATION FAILED$
79
--
810
--
911
Verification:
1012
function | pre-cond | post-cond
1113
---------|----------|----------
1214
f1 | assumed | asserted
13-
f2_out | assumed | asserted
14-
f2_in | assumed | asserted
1515

1616
Test should fail:
1717
The postcondition of f2 is incorrect, considering the recursion particularity.

regression/contracts/function-calls-04/test-enf.desc

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)