Skip to content

Commit 1482c22

Browse files
author
Daniel Kroening
committed
format_expr: +, -, *, / bind stronger than ==, !=, <, <=, >, >=
1 parent ea75bbb commit 1482c22

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

regression/cbmc/show-vcc/main_prec.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int main()
2+
{
3+
__CPROVER_bool a, b, c;
4+
int x, y, z;
5+
x=y+z;
6+
a=(b==c);
7+
__CPROVER_assert(0, "some property");
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main_prec.c
3+
--show-vcc
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^some property$
7+
^\{-.*\} main::1::x!0@1#2 = main::1::y!0@1#1 \+ main::1::z!0@1#1$
8+
^\{-.*\} main::1::a!0@1#2 ⇔ \(main::1::b!0@1#1 ⇔ main::1::c!0@1#1\)$
9+
--

src/util/format_expr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
7979
(expr.id() == ID_and || expr.id() == ID_or))
8080
return false;
8181

82+
// +, -, *, / bind stronger than ==, !=, <, <=, >, >=
83+
if(
84+
(sub_expr.id() == ID_plus || sub_expr.id() == ID_minus ||
85+
sub_expr.id() == ID_mult || sub_expr.id() == ID_div) &&
86+
(expr.id() == ID_equal || expr.id() == ID_notequal || expr.id() == ID_lt ||
87+
expr.id() == ID_gt || expr.id() == ID_le || expr.id() == ID_ge))
88+
{
89+
return false;
90+
}
91+
8292
return true;
8393
}
8494

0 commit comments

Comments
 (0)