File tree Expand file tree Collapse file tree 5 files changed +61
-2
lines changed
src/goto-instrument/contracts Expand file tree Collapse file tree 5 files changed +61
-2
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ int foo (int l ) __CPROVER_requires (-10 <= l && l <= 10 ) __CPROVER_ensures (
4
+ __CPROVER_return_value == __CPROVER_old (l ) + __CPROVER_old (10 ))
5
+ {
6
+ return l + 10 ;
7
+ }
8
+
9
+ int main ()
10
+ {
11
+ int l ;
12
+ __CPROVER_assume (-10 <= l && l <= 10 );
13
+ foo (l );
14
+ return 0 ;
15
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --enforce-contract foo
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^Tracking history of constant expressions is not supported yet
9
+ --
10
+ This test checks that history variables are supported for constant expressions.
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ long bar (long l , long r ) __CPROVER_requires (-10 <= l && l <= 10 )
4
+ __CPROVER_requires (-10 <= r && r <= 10 ) __CPROVER_ensures (
5
+ __CPROVER_return_value == __CPROVER_old (l ) + __CPROVER_old (r ))
6
+ {
7
+ return l + r ;
8
+ }
9
+
10
+ int foo (int l , int r ) __CPROVER_requires (-10 <= l && l <= 10 )
11
+ __CPROVER_requires (-10 <= r && r <= 10 ) __CPROVER_ensures (
12
+ __CPROVER_return_value == __CPROVER_old (l ) + __CPROVER_old (r ))
13
+ {
14
+ return bar ((long )l , (long )r );
15
+ }
16
+
17
+ int main ()
18
+ {
19
+ int n ;
20
+ __CPROVER_assume (-10 <= n && n <= 10 );
21
+ foo (n , n );
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --replace-call-with-contract bar --enforce-contract foo
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^Tracking history of typecast expressions is not supported yet
9
+ --
10
+ This test checks that history variables are supported for typecast expressions.
Original file line number Diff line number Diff line change @@ -562,9 +562,10 @@ void code_contractst::replace_history_parameter(
562
562
{
563
563
const auto ¶meter = to_history_expr (expr, id).expression ();
564
564
565
+ const auto &id = parameter.id ();
565
566
if (
566
- parameter. id () == ID_dereference || parameter. id () == ID_member ||
567
- parameter. id () == ID_symbol || parameter. id () == ID_ptrmember )
567
+ id == ID_dereference || id == ID_member || id == ID_symbol ||
568
+ id == ID_ptrmember || id == ID_constant || id == ID_typecast )
568
569
{
569
570
auto it = parameter2history.find (parameter);
570
571
You can’t perform that action at this time.
0 commit comments