Skip to content

Commit 5affe65

Browse files
author
Remi Delmas
committed
CONTRACTS: new test with ternary assignment LHS
1 parent 00906fd commit 5affe65

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdbool.h>
2+
#include <stdlib.h>
3+
4+
void foo(int a, int b)
5+
{
6+
char arr1[10];
7+
char arr2[10];
8+
char arr3[10];
9+
int i = 0;
10+
11+
while(i < 10)
12+
__CPROVER_loop_invariant(0 <= i && i <= 10)
13+
{
14+
((a > 0) ? arr1 : b > 0 ? arr2 : arr3)[i] = 0;
15+
i++;
16+
}
17+
}
18+
19+
int main()
20+
{
21+
int a;
22+
int b;
23+
foo(a, b);
24+
return 0;
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE dfcc-only
2+
main.c
3+
--dfcc main --enforce-contract foo --apply-loop-contracts
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
--
9+
checks that when assignment lhs expressions have ternary expressions,
10+
loop assigns clause checking correctly infers what gets assigned and
11+
automatically tracks targets in the both the top level and the loop write sets.

0 commit comments

Comments
 (0)