Skip to content

Commit 431d7a6

Browse files
Add tests for shadow memory accessed via void pointers
Checks that accessing shadow memory through void pointers returns the expected error messages, unless the correct casts have been applied.
1 parent b0e105e commit 431d7a6

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
struct STRUCTNAME
5+
{
6+
int x1;
7+
int B1[3];
8+
};
9+
10+
void f_void_ptr(void *s)
11+
{
12+
assert(__CPROVER_get_field(s, "field1") == 0);
13+
}
14+
15+
int main()
16+
{
17+
__CPROVER_field_decl_local("field1", (char)0);
18+
19+
struct STRUCTNAME z;
20+
f_void_ptr(&z);
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
Shadow memory: cannot get shadow memory via type void\* for f_void_ptr::s
7+
--
8+
^warning: ignoring
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
struct STRUCTNAME
5+
{
6+
int x1;
7+
int B1[3];
8+
};
9+
10+
void f_void_ptr(void *s)
11+
{
12+
__CPROVER_set_field(s, "field1", 1);
13+
assert(__CPROVER_get_field((struct STRUCTNAME *)s, "field1") == 1);
14+
}
15+
16+
int main()
17+
{
18+
__CPROVER_field_decl_local("field1", (char)0);
19+
20+
struct STRUCTNAME z;
21+
f_void_ptr(&z);
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
Shadow memory: cannot set shadow memory via type void\* for f_void_ptr::s
7+
--
8+
^warning: ignoring
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
struct STRUCTNAME
5+
{
6+
int x1;
7+
int B1[3];
8+
};
9+
10+
void f_void_ptr_cast(void *s)
11+
{
12+
assert(__CPROVER_get_field((struct STRUCTNAME *)s, "field1") == 0);
13+
__CPROVER_set_field(&((struct STRUCTNAME *)s)->x1, "field1", 1);
14+
assert(__CPROVER_get_field((struct STRUCTNAME *)s, "field1") == 1);
15+
}
16+
17+
int main()
18+
{
19+
__CPROVER_field_decl_local("field1", (char)0);
20+
21+
struct STRUCTNAME z;
22+
f_void_ptr_cast(&z);
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)