File tree 6 files changed +75
-3
lines changed
regression/contracts-dfcc/havoc-conditional-target
goto-instrument/contracts/dynamic-frames
6 files changed +75
-3
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ void foo (int * out )
4
+ // clang-format off
5
+ __CPROVER_requires (out == > __CPROVER_is_fresh (out , sizeof (* out )))
6
+ __CPROVER_assigns (out : * out )
7
+ __CPROVER_ensures (out == > * out == 1 )
8
+ // clang-format on
9
+ {
10
+ if (out )
11
+ * out = 1 ;
12
+ }
13
+
14
+ int nondet_int ();
15
+
16
+ void main ()
17
+ {
18
+ int * out ;
19
+ foo (out );
20
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ check-foo.c
3
+ --dfcc main --enforce-contract foo _ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
9
+ This test checks conditional havocs are behaving as expected.
Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ void foo (int * out )
4
+ // clang-format off
5
+ __CPROVER_requires (out == > __CPROVER_is_fresh (out , sizeof (* out )))
6
+ __CPROVER_assigns (out : * out )
7
+ __CPROVER_ensures (out == > * out == 1 )
8
+ // clang-format on
9
+ {
10
+ if (out )
11
+ * out = 1 ;
12
+ }
13
+
14
+ int nondet_int ();
15
+
16
+ void bar ()
17
+ {
18
+ int i = 0 ;
19
+ int * out = nondet_int () ? & i : NULL ;
20
+ foo (out );
21
+ // clang-format off
22
+ __CPROVER_assert (!out == > (i == 0 ), "out not null implies initial value" );
23
+ __CPROVER_assert (out == > (i == 1 ), "out null implies updated value" );
24
+ // clang-format on
25
+ }
26
+
27
+ int main (void )
28
+ {
29
+ bar ();
30
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ replace-foo.c
3
+ --dfcc main --enforce-contract bar --replace-call-with-contract foo _ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ --
9
+ This test checks conditional havocs are behaving as expected.
Original file line number Diff line number Diff line change @@ -1290,6 +1290,10 @@ void *__CPROVER_contracts_write_set_havoc_get_assignable_target(
1290
1290
__CPROVER_size_t idx )
1291
1291
{
1292
1292
__CPROVER_HIDE :;
1293
+ #ifdef DFCC_DEBUG
1294
+ __CPROVER_assert (write_set != 0 , "write_set not NULL" );
1295
+ #endif
1296
+
1293
1297
__CPROVER_contracts_car_t car = set -> contract_assigns .elems [idx ];
1294
1298
if (car .is_writable )
1295
1299
return car .lb ;
Original file line number Diff line number Diff line change @@ -200,10 +200,9 @@ void dfcc_spec_functionst::generate_havoc_function(
200
200
// Use same source location as original call
201
201
source_locationt location (ins_it->source_location ());
202
202
auto hook = hook_opt.value ();
203
- auto write_set_var = write_set_symbol.symbol_expr ();
204
203
code_function_callt call (
205
204
library.dfcc_fun_symbol .at (hook).symbol_expr (),
206
- {write_set_var , from_integer (next_idx, size_type ())});
205
+ {write_set_symbol. symbol_expr () , from_integer (next_idx, size_type ())});
207
206
208
207
if (hook == dfcc_funt::WRITE_SET_HAVOC_GET_ASSIGNABLE_TARGET)
209
208
{
@@ -233,7 +232,8 @@ void dfcc_spec_functionst::generate_havoc_function(
233
232
body.add (goto_programt::make_function_call (call, location));
234
233
235
234
auto goto_instruction = body.add (goto_programt::make_incomplete_goto (
236
- utils.make_null_check_expr (write_set_var)));
235
+ utils.make_null_check_expr (target_expr), location));
236
+
237
237
// create nondet assignment to the target
238
238
side_effect_expr_nondett nondet (target_type, location);
239
239
body.add (goto_programt::make_assignment (
You can’t perform that action at this time.
0 commit comments