File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
regression/cbmc/Quantifiers-type2 Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ int main()
55
66 // clang-format off
77 // clang-format would rewrite the "==>" as "== >"
8- __CPROVER_assume ( __CPROVER_forall { char i ; (i >=0 && i < 2 ) == > b [i ]>=10 && b [i ]<=10 } );
8+ __CPROVER_assume ( __CPROVER_forall { signed char i ; (i >=0 && i < 2 ) == > b [i ]>=10 && b [i ]<=10 } );
99 __CPROVER_assume ( __CPROVER_forall { unsigned i ; (i >=0 && i < 2 ) == > c [i ]>=10 && c [i ]<=10 } );
1010 // clang-format on
1111
Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ int b [2 ];
4+ int c [2 ];
5+
6+ // clang-format off
7+ // clang-format would rewrite the "==>" as "== >"
8+ __CPROVER_assume ( __CPROVER_forall { unsigned char i ; (i >=0 && i < 2 ) == > b [i ]>=10 && b [i ]<=10 } );
9+ __CPROVER_assume ( __CPROVER_forall { unsigned i ; (i >=0 && i < 2 ) == > c [i ]>=10 && c [i ]<=10 } );
10+ // clang-format on
11+
12+ assert (b [0 ] == 10 && b [1 ] == 10 );
13+ assert (c [0 ] == 10 && c [1 ] == 10 );
14+
15+ return 0 ;
16+ }
Original file line number Diff line number Diff line change 1+ CORE no-new-smt
2+ unsigned-char.c
3+
4+ ^\*\* Results:$
5+ ^\[main.assertion.1\] line 12 assertion b\[.*0\] == 10 && b\[.*1\] == 10: SUCCESS$
6+ ^\[main.assertion.2\] line 13 assertion c\[.*0\] == 10 && c\[.*1\] == 10: SUCCESS$
7+ ^VERIFICATION SUCCESSFUL$
8+ ^EXIT=0$
9+ ^SIGNAL=0$
10+ --
11+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -975,6 +975,34 @@ simplify_exprt::simplify_typecast(const typecast_exprt &expr)
975975 else if (op_id==ID_ashr || op_id==ID_lshr || op_id==ID_shl)
976976 {
977977 }
978+ else if (op_id == ID_zero_extend)
979+ {
980+ const exprt &zero_extended_op = to_zero_extend_expr (expr.op ());
981+ if (
982+ auto bv_type =
983+ type_try_dynamic_cast<bitvector_typet>(zero_extended_op.type ()))
984+ {
985+ DATA_INVARIANT (
986+ bv_type->get_width () <= to_bitvector_type (op_type).get_width (),
987+ " zero extension must not reduce bit width" );
988+
989+ auto new_expr = expr;
990+ new_expr.op () = zero_extended_op;
991+ return changed (simplify_typecast (new_expr)); // rec. call
992+ }
993+ }
994+ else if (op_id == ID_concatenation)
995+ {
996+ const auto &operands = expr.op ().operands ();
997+ if (
998+ operands.size () == 2 && operands.front ().is_constant () &&
999+ to_constant_expr (operands.front ()).value_is_zero_string ())
1000+ {
1001+ auto new_expr = expr;
1002+ new_expr.op () = operands.back ();
1003+ return changed (simplify_typecast (new_expr)); // rec. call
1004+ }
1005+ }
9781006 }
9791007 }
9801008
You can’t perform that action at this time.
0 commit comments