Skip to content

Commit 24883f0

Browse files
author
Daniel Kroening
committed
smt2 parser: concat is multi-ary
1 parent 9384c1b commit 24883f0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

scripts/delete_failing_smt2_solver_tests

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ rm equality_through_struct_containing_arrays2/test.desc
8888
rm equality_through_union1/test.desc
8989
rm equality_through_union2/test.desc
9090
rm equality_through_union3/test.desc
91-
rm gcc_bswap1/test.desc
92-
rm gcc_vector1/test.desc
9391
rm graphml_witness1/test.desc
9492
rm memory_allocation1/test.desc
9593
rm pointer-function-parameters-struct-mutual-recursion/test.desc

src/solvers/smt2/smt2_parser.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Author: Daniel Kroening, [email protected]
1111
#include "smt2_format.h"
1212

1313
#include <util/arith_tools.h>
14+
#include <util/range.h>
15+
16+
#include <numeric>
1417

1518
smt2_parsert::tokent smt2_parsert::next_token()
1619
{
@@ -612,15 +615,17 @@ exprt smt2_parsert::function_application()
612615
}
613616
else if(id=="concat")
614617
{
615-
if(op.size()!=2)
616-
throw error("concat takes two operands");
618+
// add the widths
619+
auto op_width = make_range(op).map([](const exprt &o) {
620+
return to_unsignedbv_type(o.type()).get_width();
621+
});
617622

618-
auto width0=to_unsignedbv_type(op[0].type()).get_width();
619-
auto width1=to_unsignedbv_type(op[1].type()).get_width();
623+
const std::size_t total_width =
624+
std::accumulate(op_width.begin(), op_width.end(), 0);
620625

621-
unsignedbv_typet t(width0+width1);
626+
const unsignedbv_typet t(total_width);
622627

623-
return binary_exprt(op[0], ID_concatenation, op[1], t);
628+
return concatenation_exprt(std::move(op), t);
624629
}
625630
else if(id=="distinct")
626631
{

0 commit comments

Comments
 (0)