Skip to content

Commit 94bf1fc

Browse files
committed
Re-add multiple accesses tests
Also merge multiple magic comments in function specs to avoid deprecation warning of rems-project/cerberus#889
1 parent d48f142 commit 94bf1fc

File tree

4 files changed

+217
-0
lines changed

4 files changed

+217
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
int x = 5;
2+
long y = 6;
3+
int *p = &x;
4+
5+
int
6+
main()
7+
/*@ accesses x, y, p;
8+
requires
9+
x == 5i32;
10+
y == 6i64;
11+
p == &x;
12+
ensures return == 0i32; @*/
13+
{
14+
if (x != 5)
15+
return 1;
16+
if (y != 6)
17+
return 2;
18+
if (*p != 5)
19+
return 3;
20+
return 0;
21+
}
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
int x = 10;
2+
3+
struct S {int a; int *p;};
4+
struct S s = { .p = &x, .a = 1};
5+
6+
int
7+
main()
8+
/*@ accesses s, x;
9+
requires
10+
x == 10i32;
11+
s.p == &x; s.a == 1i32;
12+
ensures return == 0i32; @*/
13+
{
14+
if(s.a != 1)
15+
return 1;
16+
if(*s.p != 10)
17+
return 2;
18+
return 0;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// TODO: could probably remove some of these requires clauses
2+
3+
int a;
4+
unsigned b;
5+
char c;
6+
signed char d;
7+
unsigned char e;
8+
long f;
9+
unsigned long g;
10+
long long h;
11+
unsigned long long i;
12+
short j;
13+
unsigned short k;
14+
15+
int
16+
main(void)
17+
/*@ accesses a, b, c, d, e, f, g, h, i, j, k;
18+
19+
requires (i128) MINi32() <= (i128) b; (i128) b <= (i128) MAXi32();
20+
21+
(i128) MINu8() <= (i128) d; (i128) d <= (i128) MAXu8();
22+
(i128) MINu8() <= (i128) f; (i128) f <= (i128) MAXu8();
23+
(i128) MINu8() <= (i128) h; (i128) h <= (i128) MAXu8();
24+
(i128) MINu8() <= (i128) i; (i128) i <= (i128) MAXu8();
25+
(i128) MINu8() <= (i128) j; (i128) j <= (i128) MAXu8();
26+
27+
(i128) MINi8() <= (i128) e; (i128) e <= (i128) MAXi8();
28+
(i128) MINi8() <= (i128) f; (i128) f <= (i128) MAXi8();
29+
(i128) MINi8() <= (i128) g; (i128) g <= (i128) MAXi8();
30+
(i128) MINi8() <= (i128) h; (i128) h <= (i128) MAXi8();
31+
(i128) MINi8() <= (i128) i; (i128) i <= (i128) MAXi8();
32+
(i128) MINi8() <= (i128) j; (i128) j <= (i128) MAXi8();
33+
(i128) MINi8() <= (i128) k; (i128) k <= (i128) MAXi8();
34+
35+
ensures return == 0i32; @*/
36+
{
37+
a = b;
38+
a = c;
39+
a = d;
40+
a = e;
41+
a = f;
42+
a = g;
43+
a = h;
44+
a = i;
45+
a = j;
46+
a = k;
47+
48+
b = a;
49+
b = c;
50+
b = d;
51+
b = e;
52+
b = f;
53+
b = g;
54+
b = h;
55+
b = i;
56+
b = j;
57+
b = k;
58+
59+
c = a;
60+
c = b;
61+
c = d;
62+
c = e;
63+
c = f;
64+
c = g;
65+
c = h;
66+
c = i;
67+
c = j;
68+
c = k;
69+
70+
d = a;
71+
d = b;
72+
d = c;
73+
d = e;
74+
d = f;
75+
d = g;
76+
d = h;
77+
d = i;
78+
d = j;
79+
d = k;
80+
81+
e = a;
82+
e = b;
83+
e = c;
84+
e = d;
85+
e = f;
86+
e = g;
87+
e = h;
88+
e = i;
89+
e = j;
90+
e = k;
91+
92+
f = a;
93+
f = b;
94+
f = c;
95+
f = d;
96+
f = e;
97+
f = g;
98+
f = h;
99+
f = i;
100+
f = j;
101+
f = k;
102+
103+
g = a;
104+
g = b;
105+
g = c;
106+
g = d;
107+
g = e;
108+
g = f;
109+
g = h;
110+
g = i;
111+
g = j;
112+
g = k;
113+
114+
h = a;
115+
h = b;
116+
h = c;
117+
h = d;
118+
h = e;
119+
h = f;
120+
h = g;
121+
h = i;
122+
h = j;
123+
h = k;
124+
125+
i = a;
126+
i = b;
127+
i = c;
128+
i = d;
129+
i = e;
130+
i = f;
131+
i = g;
132+
i = h;
133+
i = j;
134+
i = k;
135+
136+
j = a;
137+
j = b;
138+
j = c;
139+
j = d;
140+
j = e;
141+
j = f;
142+
j = g;
143+
j = h;
144+
j = i;
145+
j = k;
146+
147+
k = a;
148+
k = b;
149+
k = c;
150+
k = d;
151+
k = e;
152+
k = f;
153+
k = g;
154+
k = h;
155+
k = j;
156+
k = i;
157+
158+
return 0;
159+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Write to two static global memory cells
2+
3+
static int *cell1, *cell2;
4+
void write_4()
5+
/*@ accesses cell1, cell2;
6+
requires
7+
take Cell1Pre = Owned<int>(cell1);
8+
take Cell2Pre = Owned<int>(cell2);
9+
ensures
10+
take Cell1Post = Owned<int>(cell1);
11+
take Cell2Post = Owned<int>(cell2);
12+
Cell1Post == 7i32;
13+
Cell2Post == 8i32; @*/
14+
{
15+
*cell1 = 7;
16+
*cell2 = 8;
17+
}

0 commit comments

Comments
 (0)