Skip to content

Commit ee91d9c

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

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
8888
(expr.id() == ID_and || expr.id() == ID_or))
8989
return false;
9090

91+
// +, -, *, / bind stronger than ==, !=, <, <=, >, >=
92+
if(
93+
(sub_expr.id() == ID_plus || sub_expr.id() == ID_minus ||
94+
sub_expr.id() == ID_mult || sub_expr.id() == ID_div) &&
95+
(expr.id() == ID_equal || expr.id() == ID_notequal || expr.id() == ID_lt ||
96+
expr.id() == ID_gt || expr.id() == ID_le || expr.id() == ID_ge))
97+
return false;
98+
9199
return true;
92100
}
93101

0 commit comments

Comments
 (0)