@@ -897,11 +897,29 @@ void interpretert::evaluate(
897
897
true ); // fail quietly
898
898
if (address.is_zero ())
899
899
{
900
- // Try reading from a constant -- simplify_expr has all the relevant cases
901
- // (index-of-constant-array, member-of-constant-struct and so on)
902
- // Note we complain of a problem even if simplify did *something* but
903
- // still left us with an unresolved index, member, etc.
904
- exprt simplified = simplify_expr (expr, ns);
900
+ exprt simplified;
901
+ // In case of being an indexed access, try to evaluate the index, then
902
+ // simplify.
903
+ if (expr.id () == ID_index)
904
+ {
905
+ exprt evaluated_index = expr;
906
+ mp_vectort idx;
907
+ evaluate (expr.op1 (), idx);
908
+ if (idx.size () == 1 )
909
+ {
910
+ evaluated_index.op1 () =
911
+ constant_exprt (integer2string (idx[0 ]), expr.op1 ().type ());
912
+ }
913
+ simplified = simplify_expr (evaluated_index, ns);
914
+ }
915
+ else
916
+ {
917
+ // Try reading from a constant -- simplify_expr has all the relevant cases
918
+ // (index-of-constant-array, member-of-constant-struct and so on)
919
+ // Note we complain of a problem even if simplify did *something* but
920
+ // still left us with an unresolved index, member, etc.
921
+ simplified = simplify_expr (expr, ns);
922
+ }
905
923
if (simplified.id () == expr.id ())
906
924
evaluate_address (expr); // Evaluate again to print error message.
907
925
else
0 commit comments