Skip to content

Commit 07dedc7

Browse files
committed
index_exprt now requires a type with subtype
This commit adds a precondition to the constructor of index_exprt that enforces that the type of the 'array' operand has a subtype.
1 parent 1d9c23c commit 07dedc7

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

src/cpp/cpp_constructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
100100
exprt constant = from_integer(i, c_index_type());
101101
constant.add_source_location()=source_location;
102102

103-
index_exprt index(object, constant);
103+
index_exprt index = index_exprt(object_tc, constant);
104104
index.add_source_location()=source_location;
105105

106106
if(!operands.empty())

src/util/std_expr.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,7 @@ class index_exprt:public binary_exprt
14171417
_array,
14181418
ID_index,
14191419
std::move(_index),
1420-
_array.type().has_subtype()
1421-
? to_type_with_subtype(_array.type()).subtype()
1422-
: typet(ID_nil))
1420+
to_type_with_subtype(_array.type()).subtype())
14231421
{
14241422
}
14251423

unit/solvers/smt2_incremental/object_tracking.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ TEST_CASE("find_object_base_expression", "[core][smt2_incremental]")
2929
{member_exprt{object_base, "baz", unsignedbv_typet{8}}, pointer_type}},
3030
rowt{
3131
"Address of index of struct member",
32-
{index_exprt{
33-
member_exprt{object_base, "baz", unsignedbv_typet{8}}, index},
32+
{index_exprt{member_exprt{object_base, "baz", base_type}, index},
3433
pointer_type}},
3534
rowt{
3635
"Address of struct member at index",

0 commit comments

Comments
 (0)