Skip to content

Commit 4fbc45a

Browse files
NlightNFotisEnrico Steffinlongo
authored andcommitted
Add regression tests for SM typecheck.
1 parent f200688 commit 4fbc45a

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Created by Fotis Koutoulakis on 19/09/2023.
3+
//
4+
#include <assert.h>
5+
#include <stdio.h>
6+
7+
struct S
8+
{
9+
int i;
10+
int j;
11+
};
12+
13+
int main()
14+
{
15+
__CPROVER_field_decl_local("uninitialized", (char)0);
16+
__CPROVER_field_decl_global("uninitialized-global", (char)0);
17+
18+
struct S s;
19+
char a;
20+
21+
__CPROVER_set_field(&a, "uninitialized", 1);
22+
23+
assert(__CPROVER_get_field(&a, "uninitialized") == 1);
24+
25+
__CPROVER_set_field(&s, "uninitialized", 1);
26+
27+
assert(__CPROVER_get_field(&s, "uninitialized") == 1);
28+
assert(__CPROVER_get_field(&s.i, "uninitialized") == 1);
29+
assert(__CPROVER_get_field(&s.j, "uninitialized") == 1);
30+
31+
return 0;
32+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
intrinsics_warn.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
WARNING: no body for function
10+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_global' is not declared
11+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_local' is not declared
12+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_set_field' is not declared
13+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_get_field' is not declared
14+
--
15+
This test is making sure that we don't get any of the log messages warning
16+
for the shadow memory intrinsics being undefined after the type check phase.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CORE
2+
typechecking_warning.c
3+
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
^CONVERSION ERROR$
7+
file typechecking_warning\.c line \d function main: __CPROVER_field_decl_local argument 2 must be a byte-sized integer, but \(10ul\) has type `unsigned long int`
8+
--
9+
^warning: ignoring
10+
WARNING: no body for function
11+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_global' is not declared
12+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_local' is not declared
13+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_set_field' is not declared
14+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_get_field' is not declared
15+
--
16+
This test is part of a suite of tests we have for ensuring that the typechecker
17+
comes up with proper error messages in the case of shadow memory intrinsics
18+
failing the typechecking phase.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// Created by Fotis Koutoulakis on 19/09/2023.
3+
//
4+
int main()
5+
{
6+
__CPROVER_field_decl_local("uninitialized", 10ul);
7+
8+
return 0;
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CORE
2+
typechecking_warning.c
3+
4+
^EXIT=6$
5+
^SIGNAL=0$
6+
^CONVERSION ERROR$
7+
file typechecking_warning\.c line \d function main: __CPROVER_field_decl_local takes exactly 2 arguments, but 1 were provided
8+
--
9+
^warning: ignoring
10+
WARNING: no body for function
11+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_global' is not declared
12+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_field_decl_local' is not declared
13+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_set_field' is not declared
14+
file intrinsics_warn.c line \d+ function main: function '__CPROVER_get_field' is not declared
15+
--
16+
This test is part of a suite of tests we have for ensuring that the typechecker
17+
comes up with proper error messages in the case of shadow memory intrinsics
18+
failing the typechecking phase.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// Created by Fotis Koutoulakis on 19/09/2023.
3+
//
4+
int main()
5+
{
6+
__CPROVER_field_decl_local("uninitialized");
7+
8+
return 0;
9+
}

0 commit comments

Comments
 (0)