Skip to content

Commit 246af82

Browse files
committed
Adds memory-primitive flag to contracts regression tests
CBMC relies on memory primitives to check frame conditions. We should ensure that regression tests for contracts do not use these primitives with invalid pointers. Signed-off-by: Felipe R. Monteiro <[email protected]>
1 parent d508a3a commit 246af82

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

regression/contracts/assigns_enforce_16/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--enforce-all-contracts
3+
--enforce-all-contracts _ --pointer-primitive-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#include <assert.h>
2+
#include <stdlib.h>
23

34
int y;
45
double z;
56

6-
void bar(char **c) __CPROVER_assigns(y, z, **c) __CPROVER_ensures(**c == 6)
7+
void bar(char *c) __CPROVER_assigns(y, z, *c) __CPROVER_ensures(*c == 6)
78
{
89
}
910

1011
int main()
1112
{
12-
char **b;
13+
char *b = malloc(sizeof(*b));
1314
bar(b);
14-
assert(**b == 6);
15+
assert(*b == 6);
1516

1617
return 0;
1718
}

regression/contracts/assigns_replace_03/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--replace-all-calls-with-contracts
3+
--replace-all-calls-with-contracts _ --pointer-primitive-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/contracts/assigns_type_checking_valid_cases/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void foo5(struct buf buffer) __CPROVER_assigns(buffer)
4545
buffer.len = 0;
4646
}
4747

48-
void foo6(struct buf *buffer)
49-
__CPROVER_assigns(buffer->data, *(buffer->data), buffer->len)
48+
void foo6(struct buf *buffer) __CPROVER_assigns(buffer->data, buffer->len)
5049
{
5150
buffer->data = malloc(sizeof(*(buffer->data)));
5251
*(buffer->data) = 1;

regression/contracts/assigns_type_checking_valid_cases/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--enforce-all-contracts
3+
--enforce-all-contracts _ --pointer-primitive-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[foo1.\d+\] line \d+ Check that a is assignable: SUCCESS$

0 commit comments

Comments
 (0)