@@ -844,6 +844,43 @@ TEST_CASE(
844
844
REQUIRE (test.sent_commands == expected_commands);
845
845
}
846
846
847
+ TEST_CASE (
848
+ " smt2_incremental_decision_proceduret union support." ,
849
+ " [core][smt2_incremental]" )
850
+ {
851
+ auto test = decision_procedure_test_environmentt::make ();
852
+ // union foot{ int8_t eggs, uint32_t ham } foo;
853
+ const struct_union_typet::componentst components{
854
+ {" eggs" , unsignedbv_typet{8 }}, {" ham" , signedbv_typet{32 }}};
855
+ const type_symbolt type_symbol{" foot" , union_typet{components}, ID_C};
856
+ test.symbol_table .insert (type_symbol);
857
+ const union_tag_typet union_tag{type_symbol.name };
858
+ const symbolt union_value_symbol{" foo" , union_tag, ID_C};
859
+ test.symbol_table .insert (union_value_symbol);
860
+ // assume(foo == foot{ .eggs = 12 });
861
+ const auto symbol_expr = union_value_symbol.symbol_expr ();
862
+ const auto dozen = from_integer (12 , unsignedbv_typet{8 });
863
+ const auto union_needing_padding = union_exprt{" eggs" , dozen, union_tag};
864
+ const auto equals = equal_exprt{symbol_expr, union_needing_padding};
865
+ test.sent_commands .clear ();
866
+ test.procedure .set_to (equals, true );
867
+
868
+ // (declare-fun foo () (_ BitVec 32))
869
+ // (declare-fun padding_0 () (_ BitVec 24))
870
+ // (assert (= foo (concat padding_0 (_ bv12 8)))) }
871
+ const auto foo_term = smt_identifier_termt{" foo" , smt_bit_vector_sortt{32 }};
872
+ const auto padding_term =
873
+ smt_identifier_termt{" padding_0" , smt_bit_vector_sortt{24 }};
874
+ const std::vector<smt_commandt> expected_commands{
875
+ smt_declare_function_commandt{foo_term, {}},
876
+ smt_declare_function_commandt{padding_term, {}},
877
+ smt_assert_commandt{smt_core_theoryt::equal (
878
+ foo_term,
879
+ smt_bit_vector_theoryt::concat (
880
+ padding_term, smt_bit_vector_constant_termt{12 , 8 }))}};
881
+ REQUIRE (test.sent_commands == expected_commands);
882
+ }
883
+
847
884
TEST_CASE (
848
885
" smt2_incremental_decision_proceduret byte update-extract commands." ,
849
886
" [core][smt2_incremental]" )
0 commit comments