Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions regression/contracts-dfcc/test_aliasing_ensure/main.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>

int z;

// clang-format off
int foo(int *x, int *y)
__CPROVER_assigns(z, *x)
__CPROVER_requires(
__CPROVER_is_fresh(x, sizeof(int)) &&
*x > 0 &&
*x < 4)
__CPROVER_ensures(
__CPROVER_is_fresh(y, sizeof(int)) &&
!__CPROVER_is_fresh(x, sizeof(int)) &&
x != NULL &&
x != y &&
__CPROVER_return_value == *x + 5)
int *foo()
// clang-format off
__CPROVER_ensures(__CPROVER_is_fresh(__CPROVER_return_value, sizeof(int)))
// clang-format on
{
*x = *x + 4;
y = malloc(sizeof(*y));
*y = *x;
z = *y;
return (*x + 5);
Comment on lines -9 to -26
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precision : I rewrote this test to make it do what the test description says, i.e testing is_fresh in a post condition on the return value.

int *ret = malloc(sizeof(int));
__CPROVER_assume(ret);
return ret;
}

int main()
{
int n = 4;
n = foo(&n, &n);
assert(!(n < 4));
foo();
return 0;
}
4 changes: 0 additions & 4 deletions regression/contracts-dfcc/test_aliasing_ensure/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ main.c
^EXIT=0$
^SIGNAL=0$
\[foo.postcondition.\d+\].*Check ensures clause of contract contract::foo for function foo: SUCCESS$
\[foo.assigns.\d+\].*Check that \*x is assignable: SUCCESS
\[foo.assigns.\d+\].*Check that \*y is assignable: SUCCESS
\[foo.assigns.\d+\].*Check that z is assignable: SUCCESS
\[main.assertion.\d+\].*assertion \!\(n \< 4\): SUCCESS
^VERIFICATION SUCCESSFUL$
--
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ int foo(int *x)
ptr_ok(x))
__CPROVER_ensures(
!ptr_ok(x) &&
!__CPROVER_is_fresh(x, sizeof(int)) &&
return_ok(__CPROVER_return_value, x))
// clang-format on
{
Expand Down
Loading
Loading