File tree 3 files changed +35
-0
lines changed
regression/goto-instrument/constant-propagation-function-call
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ int ab , bc ;
3
+ int f (int x )
4
+ {
5
+ ab = 1 + 1 + 1 + 1 ;
6
+ bc = ab + x ;
7
+ return ab + bc ;
8
+ }
9
+ int main ()
10
+ {
11
+ int a ;
12
+ a = -4 ;
13
+ int b ;
14
+ b = nondet ();
15
+ a = f (a );
16
+ assert (!(0 <= a && a < 5 && 0 <= b && b < 5 ));
17
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --constant-propagator
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ Removing returns
7
+ VERIFICATION FAILED
8
+ ASSIGN main\:\:1\:\:a \:\= 4
9
+ ASSERT ¬\(main::1::b ≥ 0\) ∨ main::1::b ≥ 5
10
+ --
11
+ ^warning: ignoring
12
+ ASSERT true
13
+ --
14
+ This tests that constants are propagated through function calls, correctly
15
+ taking into account the return value. Constant propagation should result in
16
+ simplifying away the conditions in the assertion on `a` but not the conditions
17
+ on `b`.
Original file line number Diff line number Diff line change @@ -1285,6 +1285,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
1285
1285
if (cmdline.isset (" constant-propagator" ))
1286
1286
{
1287
1287
do_indirect_call_and_rtti_removal ();
1288
+ do_remove_returns ();
1288
1289
1289
1290
log .status () << " Propagating Constants" << messaget::eom;
1290
1291
You can’t perform that action at this time.
0 commit comments