Skip to content

Commit d45be72

Browse files
committed
Add test of constant propagation through function returns
1 parent 17b86f2 commit d45be72

File tree

2 files changed

+33
-0
lines changed
  • regression/goto-instrument/constant-propagation-function-call

2 files changed

+33
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
main.c
3+
--constant-propagator
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
ASSIGN main\:\:1\:\:a \:\= 4
8+
ASSERT ¬\(main::1::b ≥ 0\) ∨ main::1::b ≥ 5
9+
--
10+
^warning: ignoring
11+
ASSERT true
12+
--
13+
This tests that constants are propagated through function calls, correctly
14+
taking into account the return value. Constant propagation should result in
15+
simplifying away the conditions in the assertion on `a` but not the conditions
16+
on `b`.

0 commit comments

Comments
 (0)