Skip to content

Commit c3cefb2

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

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
@@ -77,6 +77,16 @@ static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
7777
(expr.id() == ID_and || expr.id() == ID_or))
7878
return false;
7979

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

0 commit comments

Comments
 (0)