Skip to content

Commit 3714d25

Browse files
committed
More constant propagation
Constant propagation now yields different right-hand sides in a test.
1 parent 506b635 commit 3714d25

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

jbmc/regression/jbmc-strings/long_string/test_abort.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Test.class
33
--function Test.checkAbort --trace
44
^EXIT=10$
55
^SIGNAL=0$
6-
dynamic_object[0-9]*=\(assignment removed\)
6+
dynamic_object[0-9]*=.*\?.*
77
--
88
--
99
This tests that the object does not appear in the trace, because concretizing
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
typedef struct _pair
2+
{
3+
int x;
4+
int y;
5+
} pair;
6+
7+
int __VERIFIER_nondet_int();
8+
9+
int main(void)
10+
{
11+
pair p1 = {.x = 0, .y = __VERIFIER_nondet_int()};
12+
pair p2 = {};
13+
p2.x = __VERIFIER_nondet_int();
14+
15+
__CPROVER_assert(p1.x == p2.y, "true by constant propagation");
16+
17+
return 0;
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
^Generated 1 VCC\(s\), 0 remaining after simplification$
8+
--
9+
^warning: ignoring

src/goto-symex/goto_symex_state.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ class goto_symex_is_constantt : public is_constantt
155155
*/
156156
return false;
157157
}
158+
else if(expr.id() == ID_nondet_symbol)
159+
return true;
158160

159161
return is_constantt::is_constant(expr);
160162
}

src/util/expr_util.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,12 @@ bool is_constantt::is_constant_address_of(const exprt &expr) const
276276

277277
return is_constant(deref.pointer());
278278
}
279-
else if(expr.id() == ID_string_constant)
279+
else if(
280+
expr.id() == ID_string_constant || expr.id() == ID_array ||
281+
expr.id() == ID_struct || expr.id() == ID_union)
282+
{
280283
return true;
284+
}
281285

282286
return false;
283287
}

0 commit comments

Comments
 (0)